Reputation: 107
I'm using smtplib
to send emails using sendmail()
function, how to know if email was sent or not as the function doesn't return a response code
import smtplib
s = smtplib.SMTP('smtp-mail.outlook.com', 587)
s.starttls()
s.login('[email protected]', 'mypassword')
s.sendmail('[email protected]', '[email protected]', 'message')
s.quit()
Upvotes: 2
Views: 3339
Reputation: 887
From the documentation:
This method will return normally if the mail is accepted for at least one recipient. Otherwise it will raise an exception. That is, if this method does not raise an exception, then someone should get your mail. If this method does not raise an exception, it returns a dictionary, with one entry for each recipient that was refused. Each entry contains a tuple of the SMTP error code and the accompanying error message sent by the server.
Upvotes: 1