Python has provided smtplib library in order to send email.
import smtplib#domain name for the smtp server and port numberconn = smtplib.SMTP('smtp.gmail.com',587)
type(conn)
conn.ehlo() #ehlo method to connect to the smtp mail server
conn.starttls() #starttle method to start encryption
conn.login(SENDER_EMAIL,SENDER_PASSWORD)
#you need to enter the app specific password in order to loginconn.sendmail(FROM_EMAIL_ADDRESS,TO_EMAIL_ADDRESS,'Subject: Test Email \n
\nDear All, \n So long, and thanks.\n\n-Al')
conn.quit()
Do comment if you like the post.
No comments:
Post a Comment