smtplib starttls gmail example

py py at th.on
Tue Jan 23 12:25:24 EST 2007


from smtplib import SMTP
from socket import sslerror         #if desired
server = SMTP('smtp.gmail.com')
server.set_debuglevel(0) # or 1 for verbosity
server.ehlo('youraddress at gmail.com')
server.starttls()
server.ehlo('youraddress at gmail.com')  # say hello again
server.login('youraddress at gmail.com', 'yourpassword')
# i have a suspicion that smptlib does not add the required newline dot newline so i do it myself
server.sendmail('youraddress at gmail.com', 're at cipient.com', message_text + '\n.\n')
# next line generates the ignorable socket.sslerror
server.quit()





More information about the Python-list mailing list