import smtplib USER = 'user@gmail.com' PASS = 'pass' def fails(): conn = smtplib.SMTP('smtp.gmail.com', port=587) conn.starttls() print(conn.login(USER, PASS)) conn.rset() conn.quit() def works(): conn = smtplib.SMTP('smtp.gmail.com', port=587) conn.ehlo() conn.starttls() conn.ehlo() print(conn.login(USER, PASS)) conn.rset() conn.quit()