2

I have a page where people can submit an email. It works, but I receive all emails from it saying that they are from myself.

Here's the view:

def signup(request):
  if request.method == 'POST': # If the form has been submitted...
    form = SignUpForm(request.POST) # A form bound to the POST data
    if form.is_valid(): # All validation rules pass
        subject = form.cleaned_data['subject']
        message = form.cleaned_data['message']
        sender = form.cleaned_data['sender']
        recipients = ['illuminatirebellion@gmail.com']

        from django.core.mail import send_mail
        send_mail(subject, message, sender, recipients)
        return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
     form = SignUpForm() # An unbound form
return render_to_response('signup.html', {'form': form,},context_instance=RequestContext(request))

And the settings:

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'illuminatirebellion@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
MANAGERS = ADMINS
Hannele
  • 9,301
  • 6
  • 48
  • 68
Damian Stelucir
  • 55
  • 1
  • 4
  • 9

1 Answers1

1

Your usage of send_mail() appears to be correct.

Assuming that Gmail is your SMTP vendor, it seems that Gmail does not support using custom From: email addresses.

Relevant:

Community
  • 1
  • 1
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395