[smtplib] how to assure login was succesful?

maurice mauricioliveiraguarda at gmail.com
Tue May 24 13:08:01 EDT 2016


Hello to all.

I have the following question:

Once my python script reaches the point where I login in my email account with: server.login(username,password) (where server server = smtplib.SMTP('smtp.office365.com:587')), it returns a tuple like this:

(235,
 '2.7.0 Authentication successful target host [address here]')

This method returns a tuple (code, resp). Just want to confirm if I use a variable to store code alone I should check if it is 235 or not, by looking at the reference it seems it is the only code value that does not raise an exception.

Thank you.


  



More information about the Python-list mailing list