0

I am getting the below error while trying to use Django sendmail using Outlook SMTP

SMTPDataError at /distribute/ (554, '5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:0C0F0000, 17.43559:0000000094000000000000000000000000000000, 20.52176:140F0E852800101064010000, 20.50032:140F0E858817101069010000, 0.35180:0A00E781, 255.23226:6E010000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:86000000, 17.43559:0000000068010000000000000000000000000000, 20.52176:140F0E85280010100A00F736, 20.50032:140F0E85881710100A00F836, 0.35180:8C010000, 255.23226:40000730, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:0A001780, 4.21921:DC040000, 255.27962:FA000000, 255.1494:A4010000, 0.37692:05000780, 0.37948:00000000, 5.33852:00000000534D545000000780, 4.56248:DC040000, 7.40748:010000000000010B05000780, 7.57132:000000000000000005000780, 1.63016:32000000, 4.39640:DC040000, 8.45434:824D851FB0676A47B811311E3F17990F00000000, 5.10786:0000000031352E32302E313239342E3032343A5455345052383430314D42303436323A34333038323065332D393530612D346435362D383863332D3037363837616130336664330005000780, 255.1750:0A008984, 255.31418:41010000, 0.22753:0A001986, 255.21817:DC040000, 4.60547:DC040000, 0.21966:4B010000, 4.30158:DC040000 [Hostname=TU4PR8401MB0462.NAMPRD84.PROD.OUTLOOK.COM]')

My settings are as below:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp-mail.outlook.com'
EMAIL_HOST_USER = '********'
EMAIL_HOST_PASSWORD = '********'
EMAIL_PORT = 587

Please help

atline
  • 28,355
  • 16
  • 77
  • 113
  • possible duplicate of [SMTPDataError at /accounts/signup/ (553, b'Relaying disallowed as webmaster@localhost')](https://stackoverflow.com/a/33401226/5312750). – Sachin Nov 12 '18 at 03:38
  • welcome to StackOverflow; please review [how to ask a good question](https://stackoverflow.com/help/how-to-ask); please provide a [minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve) – landru27 Nov 12 '18 at 04:39
  • Used below code to send email : send_mail('title', 'msg', 'from@example.com', ['RecipientID'],html_message=msg_html) –  Nov 12 '18 at 05:02

1 Answers1

0

I had an error similar to yours, and I resolved it as follows, two points that I think you have to pay attention to are:

  • EMAIL_HOST normally email hosts have this format ** smtp.nameserver.com **, example:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.outlook.com'
EMAIL_HOST_USER = '********'
EMAIL_HOST_PASSWORD = '********'
EMAIL_PORT = 587
  • When sending the email, the send_mail method has to send the email from an address in your domain, example:
from django.core.mail import send_mail

send_mail(
    'Subject here',
    'Here is the message.',
    'from@outlook.com', # pay attention here I had a problem because of that
    ['to@example.com'],
    fail_silently=False,
)