- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemailpython.py
More file actions
Latest commit
22 lines (22 loc) · 814 Bytes
/
Copy pathemailpython.py
File metadata and controls
22 lines (22 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
importsmtplib
fromemail.mime.multipartimportMIMEMultipart
fromemail.mime.textimportMIMEText
mail_content='''xxxxxxx'''
#The mail addresses and password
sender_address='xxxxxxx'
sender_pass='xxxxxxx'
receiver_address='xxxxxxx'
#Setup the MIME
message=MIMEMultipart()
message['From'] =sender_address
message['To'] =receiver_address
message['Subject'] =''#The subject line
#The body and the attachments for the mail
message.attach(MIMEText(mail_content)) #Create SMTP session for sending the mail
session=smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
session.starttls() #enable security
session.login(sender_address, sender_pass) #login with mail_id and password
text=message.as_string()
session.sendmail(sender_address, receiver_address, text)
session.quit()
print('Mail Sent')