Reputation: 1110
i'm trying to send a SMTP email from Django, using my credentials of Outlook. My code works in localhost, but when I upload my code to production server, it doesn't.
If I use my Gmail credential, it also works in production, but it doesn't with Outlook. So, I think Outlook is configured in a different way, but I dont know.
This is my view code:
def send_my_custom_email():
connection = mail.get_connection(
host = 'smtp-mail.outlook.com',
port = 25,
username = '[email protected]',
password = 'mypassword' ,
)
connection.open()
email2send = mail.EmailMessage('hello', 'hello', '[email protected]', to=['receiveremail'], connection=connection)
email2send.send()
connection.close()
I know that my configuration setting are right because it can send emails from localhost. These are my settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
I already try to check the Outlook settings, but I couldn't find anything about SMTP use.
My exact questions are:
Upvotes: 0
Views: 732
Reputation: 66256
Outlook.com only allows encrypted SMTP TLS connections on port 587. It does not even listen on port 25, that is why you get a timeout.
Upvotes: 2