0

I'm trying to send email through Django with the default SMTP backend. I configured my settings:

EMAIL_HOST = 'mail.mydomain.nl'
EMAIL_HOST_USER = 'myusername'
EMAIL_PASSWORD = 'mypassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

This is my company's own email server. When I try manage.py sendtestemail or send_mail in a view I keep getting the following error:

smtplib.SMTPRecipientsRefused: {'[email protected]': (554, b'5.7.1 <52D95A25.cm-11-1b.dynamic.ziggo.nl[X.X.X.X]>: Client host rejected: Access denied')}

I made this small script to test sending from pure Python and it works fine:

import smtplib

sender = '[email protected]'
receivers = ['[email protected]']
message = 'This script works.'

try:
   smtpObj = smtplib.SMTP('mail.mydomain.nl', 587)
   smtpObj.login('username', 'password')
   smtpObj.sendmail(sender, receivers, message)
   print('Successfully sent email')
except Exception as e:
   print('Error unable to send email {0}'.format(e))

Is there something in Django's SMTP EmailBackend that I am not aware of that could be causing the problem? This is Django 1.11.1 on Python 3.6 .

voodoo-burger
  • 2,123
  • 3
  • 22
  • 29

0 Answers0