Good day, I have a Django app that sends emails. I used a google app password for my EMAIL_HOST_PASSWORD
, it works perfectly fine, but the from_email
always set to my email which I used to create the app password instead of the email it gets from the form.
How can I fix this, please?
UPDATE
from django.shortcuts import render
from django.core.mail import send_mail
def index(request):
if request.method == "POST":
name = request.POST["name"]
email = request.POST["email"]
phone = request.POST["phone"]
message = request.POST["message"]
msg = "Email: " + email + "\n" + message + "\nPhone Number: " + phone
send_mail(
name + " Sent Us A Message",
msg,
email,
["myemail@gmail.com"],
)
return render(request, "index.html", {"name": name})
else:
return render(request, "index.html", {})