smtplib starttls gmail example

P

py

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('(e-mail address removed)')
server.starttls()
server.ehlo('(e-mail address removed)') # say hello again
server.login('(e-mail address removed)', 'yourpassword')
# i have a suspicion that smptlib does not add the required newline dot newline so i do it myself
server.sendmail('(e-mail address removed)', '(e-mail address removed)', message_text + '\n.\n')
# next line generates the ignorable socket.sslerror
server.quit()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
DewittMill
Top