|
| 1 | +from email.mime.text import MIMEText |
| 2 | +import smtplib |
| 3 | + |
| 4 | +def send_email(email, height, average_height, count): |
| 5 | + from_email="martdev1963@gmail.com" |
| 6 | + from_password="rocket12" |
| 7 | + to_email=email |
| 8 | + |
| 9 | + subject="Height Data" |
| 10 | + message="Hey there!, your height is <strong>%s</strong>. <br >Average height of all is <strong>%s</strong> and that is calculated out of <strong>%s</strong> people." % (height, |
| 11 | + average_height, count) # using tuple containing the data for the placeholders %s... |
| 12 | + |
| 13 | + msg=MIMEText(message, 'html') |
| 14 | + msg['Subject']=subject |
| 15 | + msg['To']=to_email |
| 16 | + msg['From']=from_email |
| 17 | + |
| 18 | + gmail=smtplib.SMTP('smtp.gmail.com',587) # google email server web address and port number... |
| 19 | + gmail.ehlo() |
| 20 | + gmail.starttls() |
| 21 | + gmail.login(from_email, from_password) |
| 22 | + gmail.send_message(msg) |
0 commit comments