Changeset 404
- Timestamp:
- Jun 3, 2020, 10:17:18 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
foomailer/foomail.py
r402 r404 8 8 import time 9 9 from time import gmtime,strftime 10 from email. MIMEMultipart import MIMEMultipart11 from email. MIMEBase import MIMEBase12 from email. MIMEText import MIMEText13 from email. Utils import COMMASPACE, formatdate14 from email import Encoders10 from email.mime.multipart import MIMEMultipart 11 from email.mime.base import MIMEBase 12 from email.mime.text import MIMEText 13 from email.utils import COMMASPACE, formatdate 14 from email import encoders 15 15 16 16 __svnversion__ = "$Id: foomail.py 633 2008-06-12 19:29:56Z rick $" … … 19 19 20 20 def usage(): 21 print "usage %s -f <from> -r <recipient> -s <server> [--spam]" % sys.argv[0]22 print "[--virus] [--file <size in kB>] [--message <file>]"23 print "[--subject <string>] [--to <string>] [--cc <string>]"24 print "[--force]"21 print("usage %s -f <from> -r <recipient> -s <server> [--spam]" % sys.argv[0]) 22 print("[--virus] [--file <size in kB>] [--message <file>]") 23 print("[--subject <string>] [--to <string>] [--cc <string>]") 24 print("[--force]") 25 25 26 26 default_domain = 'example.com' … … 91 91 error = False 92 92 if not sender: 93 print "No sender defined"93 print("No sender defined") 94 94 error = True 95 95 elif not recipient: 96 print "No recipient defined"96 print("No recipient defined") 97 97 error = True 98 98 elif not server: 99 print "No server defined"99 print("No server defined") 100 100 error = True 101 101 … … 128 128 email['X-Port'] = port 129 129 email['X-Hostname'] = hostname 130 email['Message-ID' ] = '<' +''.join(random.sample(string. letters +130 email['Message-ID' ] = '<' +''.join(random.sample(string.ascii_letters + 131 131 string.digits,10)) + '@' + email['X-Hostname'] + '>' 132 132 email['Date'] = strftime('%a, %d %b %Y %T %z',gmtime()) … … 156 156 Technical details:\n''' % email 157 157 158 for k in email.keys():158 for k in list(email.keys()): 159 159 v = email[k] 160 160 msg += "* %-15s : %s\n" % (k,v) … … 183 183 part = MIMEBase('application', "octet-stream") 184 184 part.set_payload('X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*') 185 Encoders.encode_base64(part)185 encoders.encode_base64(part) 186 186 part.add_header('Content-Disposition', 'attachment; filename="eicar.txt"') 187 187 email.attach(part) … … 194 194 part.set_payload(f.read()) 195 195 f.close() 196 Encoders.encode_base64(part)196 encoders.encode_base64(part) 197 197 part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file)) 198 198 email.attach(part) 199 199 200 print email.as_string()200 print(email.as_string()) 201 201 202 202 if not dry: … … 208 208 server.sendmail(sender, recipient, email.as_string()) 209 209 server.quit() 210 print "Sending took sec: %.2f" % (time.time() - mark)210 print("Sending took sec: %.2f" % (time.time() - mark))
Note:
See TracChangeset
for help on using the changeset viewer.