#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 14 11:52:03 2018

@author: saanidhi
"""


import smtplib 
from email.mime.multipart import MIMEMultipart 
from email.mime.text import MIMEText 
from email.mime.base import MIMEBase 
from email import encoders 

fromaddr = "saanidhi.1211@gmail.com"
toaddr = "xyz@gmail.com"


msg = MIMEMultipart() 


msg['From'] = fromaddr 

 
msg['To'] = toaddr 

 
msg['Subject'] = "Hilo"


body = "Test mail"

 
msg.attach(MIMEText(body, 'plain')) 


filename = "ResumeFinal.pdf" #sample file name
attachment = open("/Users/saanidhi/Desktop/ResumeFinal.pdf", "rb") 

 
p = MIMEBase('application', 'octet-stream') 


p.set_payload((attachment).read()) 

 
encoders.encode_base64(p) 

p.add_header('Content-Disposition', "attachment; filename= %s" % filename) 

 
msg.attach(p) 


s = smtplib.SMTP('smtp.gmail.com', 587) 

 
s.starttls() 
 
s.login(fromaddr, "password") 


text = msg.as_string() 

 
s.sendmail(fromaddr, toaddr, text) 


s.quit() 

f56130677a402432d05555eb9c9cd9595eefadac
<mask token>

<mask token>
msg.attach(MIMEText(body, 'plain'))
<mask token>
p.set_payload(attachment.read())
encoders.encode_base64(p)
p.add_header('Content-Disposition', 'attachment; filename= %s' % filename)
msg.attach(p)
<mask token>
s.starttls()
s.login(fromaddr, 'password')
<mask token>
s.sendmail(fromaddr, toaddr, text)
s.quit()

<mask token>
fromaddr = 'saanidhi.1211@gmail.com'
toaddr = 'xyz@gmail.com'
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = 'Hilo'
body = 'Test mail'
msg.attach(MIMEText(body, 'plain'))
filename = 'ResumeFinal.pdf'
attachment = open('/Users/saanidhi/Desktop/ResumeFinal.pdf', 'rb')
p = MIMEBase('application', 'octet-stream')
p.set_payload(attachment.read())
encoders.encode_base64(p)
p.add_header('Content-Disposition', 'attachment; filename= %s' % filename)
msg.attach(p)
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login(fromaddr, 'password')
text = msg.as_string()
s.sendmail(fromaddr, toaddr, text)
s.quit()

<mask token>
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
fromaddr = 'saanidhi.1211@gmail.com'
toaddr = 'xyz@gmail.com'
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = 'Hilo'
body = 'Test mail'
msg.attach(MIMEText(body, 'plain'))
filename = 'ResumeFinal.pdf'
attachment = open('/Users/saanidhi/Desktop/ResumeFinal.pdf', 'rb')
p = MIMEBase('application', 'octet-stream')
p.set_payload(attachment.read())
encoders.encode_base64(p)
p.add_header('Content-Disposition', 'attachment; filename= %s' % filename)
msg.attach(p)
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login(fromaddr, 'password')
text = msg.as_string()
s.sendmail(fromaddr, toaddr, text)
s.quit()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 14 11:52:03 2018

@author: saanidhi
"""


import smtplib 
from email.mime.multipart import MIMEMultipart 
from email.mime.text import MIMEText 
from email.mime.base import MIMEBase 
from email import encoders 

fromaddr = "saanidhi.1211@gmail.com"
toaddr = "xyz@gmail.com"


msg = MIMEMultipart() 


msg['From'] = fromaddr 

 
msg['To'] = toaddr 

 
msg['Subject'] = "Hilo"


body = "Test mail"

 
msg.attach(MIMEText(body, 'plain')) 


filename = "ResumeFinal.pdf" #sample file name
attachment = open("/Users/saanidhi/Desktop/ResumeFinal.pdf", "rb") 

 
p = MIMEBase('application', 'octet-stream') 


p.set_payload((attachment).read()) 

 
encoders.encode_base64(p) 

p.add_header('Content-Disposition', "attachment; filename= %s" % filename) 

 
msg.attach(p) 


s = smtplib.SMTP('smtp.gmail.com', 587) 

 
s.starttls() 
 
s.login(fromaddr, "password") 


text = msg.as_string() 

 
s.sendmail(fromaddr, toaddr, text) 


s.quit() 
