1
I set up a server with my application Django and now I’m trying to enable password reset via email using the postfix as an e-mail server.
I started configuring my views and testing if everything was correct through console e-mail backend of Django.
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
When I log on to my site and ask to reset the password I see the email correctly appearing on my terminal.
Then I set up the postfix on my server. I also tested to see if it was working correcting through the following command:
echo "Body" | mail -s "Subject" [email protected]
All right so far, the above email arrived in my test email.
After that I modified the settings.py
:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'Noreply <[email protected]>'
When I test the setting on Django shell:
from django.core.mail import send_mail
send_mail('Subject', 'Body', '[email protected]', ['[email protected]'], fail_silently=False)
Again everything happens as expected and the email arrives in my box.
But what does not work is when I access the password reset page of my site and enter my email the email does not arrive!
In my journalctl -u postfix -xe
I see the following messages:
postfix/smtpd[23411]: connect from localhost[127.0.0.1]
postfix/smtpd[23411]: 7BAED13D02E: client=localhost[127.0.0.1]
postfix/cleanup[23414]: 7BAED13D02E: message-id=<[email protected]>
postfix/qmgr[20567]: 7BAED13D02E: from=<[email protected]>, size=974, nrcpt=1 (queue active)
postfix/smtpd[23411]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
postfix/smtp[23415]: connect to gmail-smtp-in.l.google.com[xxxx:xxxx:xxxx:xxx::xx]:25: Network is unreachable
postfix/smtp[23415]: 7BAED13D02E: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[xxx.xxx.xxx.xxx]:25, delay=0.32, delays=0.01/0.01/0.1/0.21, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[xxx.xxx.xxx.xx] said: 550-5.7.1 [xxx.xxx.xx.xxx 13] Messages with multiple addresses in From: 550 5.7.1 header are not accepted. f12si6029290pln.103 - gsmtp (in reply to end of DATA command))
postfix/cleanup[23414]: CB6B913D030: message-id=<[email protected]>
postfix/qmgr[20567]: CB6B913D030: from=<>, size=3367, nrcpt=1 (queue active)
postfix/bounce[23416]: 7BAED13D02E: sender non-delivery notification: CB6B913D030
postfix/qmgr[20567]: 7BAED13D02E: removed
postfix/local[23418]: CB6B913D030: to=<[email protected]>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=5.1.1, status=bounced (unknown user: "noreply")
postfix/qmgr[20567]: CB6B913D030: removed
I believe the tip is in 13] Messages with multiple addresses in From: 550 5.7.1 header are not accepted. f12si6029290pln.103 - gsmtp (in reply to end of DATA command)
, but I don’t know how to solve...
Could you post the view code where you send the email or if you are using the Django Authentication system view ? You are following the steps from here: (https://docs.djangoproject.com/en/1.11/topics/auth/default/) ?
– Guilherme IA
I’m using the view default of the Django https://github.com/django/django/blob/master/django/contrib/auth/views.py
– Danilo Favato
I had some problems with email, due to SSL.. I used Zoho. I had to use django_smtp_ssl in EMAIL_BACKEND and put the flag for EMAIL_USE_SSL for True. In this case, is your port correct? Is it really 25? I don’t know if it interferes, but on DEFAULT_FROM_EMAIL, I only put the email and not Spaces and characters. But I don’t know if it interferes with anything either. A tip too, is to use queues to send the email. Queue and send manually, as you did, by throwing an X amount at a time from the queue.
– Guilherme IA