Python smtplib: Gmail works, but only “sometimes”
问题 I wrote a simple script to send an email via the Gmail SMTP server. Here the code: import smtplib msg = 'Hello World!' server = smtplib.SMTP('smtp.gmail.com', 587) #port 465 or 587 server.ehlo() server.starttls() server.ehlo() server.login('username@googlemail.com','password') server.sendmail('username@googlemail.com','username@googlemail.com', msg) server.close() Sometimes it works and sometimes I get an error. What is the reason for it? I have configured Gmail for accepting less secure apps