from django.contrib import messages from django.core.mail import send_mail from django.shortcuts import redirect def send_login_email(request): email = request.POST["email"] send_mail( "A magic login link to your Dashboard", "Use this magic link to login to your Dashboard", "adman@howdy.earthmanrpg.me", [email], ) messages.success( request, "Check your email!—there you'll find a magic login link. But hurry… it's only temporary!", ) return redirect("/")