Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #318 from ani-thanvi/contri-python
Browse files Browse the repository at this point in the history
pyhton code to send a mail
  • Loading branch information
Harshsngh07 committed Oct 19, 2020
2 parents 3322dc1 + 130b72e commit 14d4e7c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Language/Python/Send_a_mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#This program will let you draft and send the mail.


import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
host_mail="******@gmail.com" #Enter your mail id.
host_pass="****" #Enter your mail's password.
guest_mail="*****@gmail.com" #Enter the mail id of the guest whom you want to send the mail.
subject="Mailing through python code"
body="successfully sent the mail"
message = MIMEMultipart()
message['From']=host_mail
message['To']=guest_mail
message['Subject']=subject
message.attach(MIMEText(body,'plain'))
session= smtplib.SMTP('smtp.gmail.com',587)
session.starttls()
session.login(host_mail,host_pass)
text=message.as_string()
session.sendmail(host_mail,guest_mail,text)
session.quit()
print("Mail sent successfully")

0 comments on commit 14d4e7c

Please sign in to comment.