SMTP mail getting bounced using Heroku, Django and Outlook (goDaddy)

Viewed 125

So I'm having some issues with sending emails using SMTP with Django, Heroku and a GoDaddy (office 365) email.

My email setup is as such:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.office365.com' 
EMAIL_HOST_USER = HOSTUSER
EMAIL_HOST_PASSWORD = LOCALPASSWORD
EMAIL_PORT = 587
EMAIL_USE_TLS = True

If I send a standard test e-mail LOCALLY (i.e. by running my app locally) like this:

import django
django.setup()
from django.conf import settings
from django.core.mail import send_mail

send_mail(
    subject = 'That’s your subject',
    message = 'That’s your message body',
    from_email = settings.EMAIL_HOST_USER,
    recipient_list = [some_email_address,],    
    fail_silently = False
)

It works just fine. Also, I am able to send e-mails as normal through my Outlook webmail.

However, when I launch this app to Heroku and try to send a test e-mail, I get a bounce-back to my webmail that looks like this:

Remote Server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP. For more information please go to http://go.microsoft.com/fwlink/?LinkId=526653 AS(8561) [CWXP265MB3078.GBRP265.PROD.OUTLOOK.COM]'

Received: from CWLP265MB3922.GBRP265.PROD.OUTLOOK.COM
([fe80::f472:c360:b020:723b]) by CWLP265MB3922.GBRP265.PROD.OUTLOOK.COM
([fe80::f472:c360:b020:723b%6]) with mapi id 15.20.4308.022; Thu, 8 Jul 2021
16:29:32 +0000
MIME-Version: 1.0
Content-Type: text/plain
Date: Thu, 8 Jul 2021 16:29:32 +0000
Message-ID:
162576177199.10.1317079512283763999@7b074c75-3c7b-4c2c-9dc4-caf0ce6cbd26.prvt.dyno.rt.heroku.com

So it seems to me that the IP address assigned to the site / domain by Heroku is causing the problem. However, Heroku are claiming it's not their problem, and GoDaddy support told me it's not their problem... I've tried restarting my Heroku dyno, and have even tried migrating it to a different app name and I'm still getting the bounce-back. Anyone have any sage advice to offer? I'm running in circles

0 Answers
Related