I want to send mail with smtp
lib on python. I understand that it uses local smtp service on port number 25. I have below codes. These codes run on my local without any problem and mail sends successfully. But when I move them to docker container, mail is not sent and it doesn't give any error.
My codes:
from_mail = '[email protected]'
to_mail = '[email protected]'
s = smtplib.SMTP('localhost')
subject = 'Test Subject'
content = 'content test'
message = f"""\
Subject: {subject}
To: {to_mail}
From: {from_mail}
{content}"""
result = s.sendmail(from_mail, to_mail, message)
s.quit()
After running these codes, I get empty dict ({}) as result
value. In the sendmail method description has this:
... the message was accepted for delivery to three of the four addresses, and one was rejected, with the error code 550. If all addresses are accepted, then the method will return an empty dictionary.
Is it about network configuration? Should I configure any network settings?
python:3.6-slim-buster
– Tonita