Advertisement
AZZATSSINS_CYBERSERK

Mailer

Sep 8th, 2017
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import smtplib
  4. from email.MIMEMultipart import MIMEMultipart
  5. from email.MIMEText import MIMEText
  6. def checkConnection(server, port, tls, user, passwd):
  7.     try:
  8.         connect = smtplib.SMTP(server, port)
  9.         connect.ehlo()
  10.         if tls:
  11.           connect.starttls()
  12.           connect.ehlo()
  13.         connect.login(user, passwd)
  14.         return connect
  15.     except:
  16.         return False
  17. def inboxEmail(server, port, tls, user, passwd, maillist, From, subject, mailtext):
  18.     smtpConnect = checkConnection(server, port, tls, user, passwd)
  19.     emails = len(maillist)
  20.     for success, sendto in enumerate(maillist):
  21.         content = MIMEMultipart()
  22.         content['From'] = From
  23.         content['To'] = sendto.rstrip()
  24.         content['Subject'] = subject
  25.         htmlscript = mailtext.rstrip()
  26.         content.attach(MIMEText(htmlscript, 'html'))
  27.         print('SMTP Email Sender >>> You are going to send to '+sendto.rstrip())
  28.         smtpConnect.sendmail(From, sendto.rstrip(), content.as_string())
  29.     smtpConnect.quit()
  30.     print('\nEmail Sender >>> Email to '+str(success+1)+'/'+str(emails)+' Adresses sended!\n')
  31. print"""
  32.   ___ ________  ___ ___________________  ______
  33.  / _ /_  /_  / / _ /_  __/ __/ __/  _/ |/ / __/
  34. / __ |/ /_/ /_/ __ |/ / _\ \_\ \_/ //    /\ \
  35. /_/ |_/___/___/_/ |_/_/ /___/___/___/_/|_/___/  
  36.                                                
  37.  
  38.                                                          """
  39. print('--------------#>> CLAY  (Author) FsocietyTN <<#-------------- ')
  40. print('')
  41. smtpServer = raw_input('\nPlease enter the SMTP Server (Hostname or IP Adress): ')
  42. smtpPort = input('Please enter the SMTP Port : ')
  43. smtpTLS = input('Secure the Email with TLS ? (Yes [1] or No [0]): ')
  44. smtpUser = raw_input('Enter the SMTP Username: ')
  45. smtpPass = raw_input('Enter the SMTP Password: ')
  46. if checkConnection(smtpServer, smtpPort, smtpTLS, smtpUser, smtpPass,):
  47.     print('\nPr0 SMTP Email Sender >>> SMTP Status // Connected!')
  48.     sendFrom = raw_input('\nEnter the Receiver: ')
  49.     sendSubj = raw_input('Enter the Subject: ')
  50.     userlist = raw_input('Enter the Path of the Email List: ')
  51.     try:
  52.         maillist = open(userlist).readlines()
  53.         print('\n Pr0 SMTP Email Sender >>> I found currently '+str(len(maillist))+' Email Adresses.')
  54.         htmlscript = raw_input('\nEnter here the Path to your HTML Script: ')
  55.         try:
  56.             html = open(htmlscript).read()
  57.             raw_input('ENTER, to send the HTML Script to '+str(len(maillist))+' ...\n')
  58.             try:
  59.                 inboxEmail(smtpServer, smtpPort, smtpTLS, smtpUser, smtpPass, maillist, sendFrom, sendSubj, html)
  60.             except:
  61.                 print('ERROR: I CANT USE THE EMAIL!')
  62.         except:
  63.             print('The HTML File cannot get readed yet or is empty.')
  64.     except:
  65.         print('The .txt File cannot get readed or is empty.')
  66. else:
  67.     print('I cant connect to the Server :/')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement