Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Connection...
- import smtplib
- import os
- # Message Body....
- from email import Encoders
- from email.MIMEBase import MIMEBase
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- print '''
- # Python Email Sender.
- # Author: Muhammad Adeel aka Innoxent Stoker
- # FB: http://facebook.com/xtoker
- # Email: [email protected]
- _\|/_
- (o o)
- +----oOO-{_}-OOo--------------+
- |==> author: Muhammad Adeel +
- +==> FB.com/xtoker +
- |==> [email protected] +
- +-----------------------------+
- | Usage: "./MailSender.py" |
- +-----------------------------+
- <<==============================>>
- +++++++++++++++++++++++++++++++
- |||||||||||||||||||||||||||||||
- +++++++++++++++++++++++++++++++
- | InnoXent Stoker |
- +++++++++++++++++++++++++++++++
- |||||||||||||||||||||||||||||||
- +++++++++++++++++++++++++++++++
- '''
- gmail_id = raw_input('Gmail Username/ID : ')
- gmail_pass =raw_input('Password: ')
- def mail(to, subject, text, attach):
- pesan = MIMEMultipart()
- pesan['From'] = gmail_id
- pesan['To'] = to
- pesan['Subject'] = sub
- pesan.attach(MIMEText(text))
- part = MIMEBase('application', 'octet-stream')
- part.set_payload(open(attach, 'rb').read())
- Encoders.encode_base64(part)
- part.add_header('Content-Disposition',
- 'attachment; filename="%s"' % os.path.basename(attach))
- pesan.attach(part)
- mailServer = smtplib.SMTP("smtp.gmail.com", 587)
- mailServer.ehlo()
- mailServer.starttls()
- mailServer.ehlo()
- mailServer.login(gmail_id, gmail_pass)
- mailServer.sendmail(gmail_id, to, pesan.as_string())
- mailServer.close()
- more_send="y"
- recepients = []
- while more_send == "y":
- get_recepient_email = raw_input("Recepient's Email: ")
- recepients.append(get_recepient_email)
- more_send = raw_input("Do you want to send more(y/n): ")
- sub = raw_input("Subject: ")
- body = raw_input("Body: ")
- file_path = raw_input("Enter attachment path: ")
- for email in recepients:
- mail(email,sub,body,file_path)
- print "Your email to "+str(email)+" was sent successfully"
Add Comment
Please, Sign In to add comment