3

If yes, how? I was not able to find anything on google.

jck
  • 1,910
  • 4
  • 18
  • 25

4 Answers4

2

In case someone is still in need of some help here... It took me a while to figure out what the EMAIL_HOST setting needed to be for an out-of-the-box MSE configuration.

EMAIL_HOST = 'outlook.office365.com'
EMAIL_HOST_USER = user@yourdomain.com
EMAIL_HOST_PASSWORD = Y0urP@$$w0rd
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

The above configuration is working fine for me using Django's default email backend.

DragonBobZ
  • 2,194
  • 18
  • 31
  • was there any special configuration you did on the office account. i've been struggling to get this fixed. my emails don't deliver and i don't get any error. – Abayomi Olowu Jun 11 '23 at 17:33
  • I don't recall, but I don't think so. Unfortunately it's very possible the above no longer works given that it was written over 5 years ago at this point. The application using this configuration is no longer in service, so I don't know. – DragonBobZ Jun 12 '23 at 17:34
  • okay i got it fixed yesterday after a week of struggling with it. – Abayomi Olowu Jun 23 '23 at 09:38
  • @AbayomiOlowu it would be great if you could share an updated answer! – DragonBobZ Jun 23 '23 at 17:18
  • 1
    what i did was to disable 2fa globally through azure dashboard. that was what caused the authentication to fail. – Abayomi Olowu Jul 03 '23 at 11:04
1

SMTP on Exchange shouldn't be any different to any other mail server. You may hit issues of anonymous access is not allowed for relaying. If only integrated authentication is enabled, have a look at;

SMTP through Exchange using Integrated Windows Authentication (NTLM) using Python

Also ensure the IP of the Django box is added to the list of relay IPs in Exchange (if enabled).

Community
  • 1
  • 1
Tom Werner
  • 319
  • 2
  • 8
  • Is there any reason why anonymous access is not allowed for relaying? I am trying to configure anonymous SMTP access for Sentry service which uses Django under the hood without any success. – antrost Jul 19 '19 at 20:50
0

Here is what my settings.py looked like and it works.

# Email Backend Service
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'yourexchangservername'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

# Use environment variables for sensitive information
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL')
wanikwai
  • 1
  • 2
-2

Sending an email in Django through a Microsoft Exchange server is possible using the SMTP protocol.

Here's an example configuration:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'your.exchange.server'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your.email@domain.com'
EMAIL_HOST_PASSWORD = 'yourpassword'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'your.email@domain.com'

Replace your.exchange.server, your.email@domain.com, and yourpassword with the appropriate values for your Exchange server and email account.

Anay
  • 741
  • 1
  • 5
  • 15