PDA

View Full Version : Mass email sender



Server_CM
10-19-2014, 12:08 PM
import smtplib import sys try: print "-----------------++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++-----------------" print "-----------------++++++++++++++++++++++++++++++++++++++--pubbi008 bulk email sender--++++++++++++++++++++++++++++++++++++++++++-----------------" print "-----------------++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++-----------------" # get the txt file containing the email addresses of recepients. Each email is written on a separate line # for example # [email protected] # [email protected] # and so on users = raw_input("\n[email sender] recepients file name: ") if ".txt" in users: pass else: print "[email sender] this is not a valid txt file" sys.exit() # get the list of recepients recepients = [] try: with open(users) as i: user_list = i.readlines() for i in user_list: recepients.append(i.strip("\n")) except IOError : print "[email sender] invalid recepients file" sys.exit() # get the required information from the user FROM = raw_input("[email sender] from: ") TO = recepients SUBJECT = raw_input("[email sender] subject: ") TEXT = raw_input("[email sender] message: ") # Prepare actual message headers = ["From: " + FROM, "Subject: " + SUBJECT, "To: " + ", ".join(TO), "MIME-Version: 1.0", "Content-Type: text/html"] headers = "\r\n".join(headers) body = "" + TEXT + "" # Credentials username = raw_input("[email sender] your gmail username: ") password = raw_input("[email sender] your gmail password: ") if "gmail.com" in username: host = "smtp.gmail.com:587" elif "ymail.com" in username: host = "smtp.ymail.com:587" elif "live.com" in username: host = "smtp.live.com:587" print "[email sender] SMTP configuration is set to %s"%host # The actual mail send print "[email sender] sending....." server = smtplib.SMTP(host) server.starttls() server.login(username,password) server.sendmail(FROM, TO, headers + "\r\n\r\n" + TEXT) server.quit() print "[email sender] email sent to all recepients"

Dare_devil
03-27-2015, 07:50 PM
nice share bro.....lets try this

ishara97
03-30-2015, 02:45 AM
thanks lot

lincecum
05-13-2017, 06:04 PM
Thanks for sharing

horusofficial
08-30-2017, 05:23 PM
Thanks for sharing

0x069
05-09-2018, 12:14 AM
Nice! thanks for sharing!

cardsplayer
03-04-2021, 10:27 PM
Nice. Good coding, love the commentaries!