#How to send an email
sendIt("recipient@gmail.com","myEmail@gmail.com", "myShortPassword", "Hello! This is the message body!\nBest,\nMe")
#How to send an email
sendIt("recipient@gmail.com","myEmail@gmail.com", "myShortPassword", "Hello! This is the message body!\nBest,\nMe")
def sendIt(to, gmail_address, gmail_pwd, body, | |
from smtplib import SMTP as smtplibsmtp | |
smtpserver = smtplibsmtp("smtp.gmail.com",587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo | |
smtpserver.login(gmail_user, gmail_pwd) | |
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n' | |
msg = header + '\n ' + body + ' \n\n' | |
smtpserver.sendmail(gmail_user, to, msg) | |
smtpserver.close() |