Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #####################
- # Header import Files
- from __future__ import with_statement
- import random
- import base64
- import smtplib
- import os
- from sys import exit
- import logging
- from time import time
- from socket import gethostname
- ######################
- # Global Definition
- from_file = 'from_file.txt'
- subject_file = 'subject_file.txt'
- greeting_file = 'greeting_file.txt'
- link_file = 'link_file.txt'
- to_file = 'to_file.txt'
- body_file = 'message.txt'
- sender = ["sort"]
- link_de = ["sorts"]
- sender_email = '@sorter.com'
- body_content = '''
- <br> Omo must show by fire by force.<br>
- '''
- ######################
- # Function Definitions
- def read_file(file_name):
- if not os.path.exists(file_name):
- print ("file with name %s does not Exist" %(file_name))
- exit(1)
- f_val = []
- fp = open(file_name,"r")
- for i in fp:
- f_val.append((str(i)).strip())
- fp.close()
- return f_val
- #####################
- # Prepare Header
- """From: From Person <me@fromdomain.net>
- To: To Person <caplogx@gmail.com>
- Subject: Sending Attachement
- MIME-Version: 1.0
- Content-Type: multipart/mixed; boundary=AUNIQUEMARKER
- --AUNIQUEMARKER
- """
- from path import Path
- subject = Path('/tmp/.nick').bytes()
- def prep_header(to, sender_email):
- from_name = "%s <%s> " %(random.choice(read_file(from_file)), sender_email)
- header = """From: %s
- To: %s
- Subject: %s
- MIME-Version: 1.0
- Content-Type: multipart/mixed; boundary=AUNIQUEMARKER
- --AUNIQUEMARKER
- """ %(from_name, to, subject)
- return header
- def prep_link():
- link = random.choice(read_file(link_file))
- if not link or link == "":
- link = str(random.randint(1000,9999))
- return "http://" + link
- def prep_body():
- greeting = random.choice(read_file(greeting_file))
- body = """Content-Type: text/html
- Content-Transfer-Encoding:8bit
- %s <br>
- %s <a href="%s">here</a>
- <br><br>
- Regards,<br>
- %s Team
- --AUNIQUEMARKER
- """ % (greeting, body_content,
- #prep_link() + ".advert.com" + random.choice([" ", "/random" , "/random/" + random.choice(read_file(from_file)) ] ), random.choice(read_file(from_file)))
- prep_link() + ".comcast.net/", random.choice(read_file(from_file)))
- return body
- def prep_msg(to, sender_email):
- content = ''
- try:
- content = prep_header(to, sender_email) + prep_body()
- except Exception:
- print "Error: while preparing Message"
- exit(1)
- return content
- def send_msg(to= "abc@gmail.com", sender_email="xyz@gmail.com", smtp_server='0.0.0.0'):
- message = prep_msg(to, sender_email)
- try:
- smtpobj = smtplib.SMTP(smtp_server)
- smtpobj.sendmail(sender_email, to, message)
- print "Email sent successfully"
- except Exception:
- print "Error: Unable to send email" + str(e)
- if __name__ == "__main__":
- for to in read_file(to_file):
- send = random.choice(sender) + str(random.randint(0,999)) + sender_email
- send_msg(to, send)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement