m0n0lithic

smtp.py

May 14th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from sys import argv
  3. SMTPserver = '172.25.1.63'
  4. sender = '[SPOA::DIMAR-CIOH] <[email protected]>'
  5. USERNAME = "WilderXXXXXXn"
  6. PASSWORD = "WNCPXXXXX"
  7. text_subtype = 'plain'
  8. # content="""\
  9. # Test Test Test
  10. # """
  11. content = argv[1]
  12. subject = "::. SPOA Status .:: " + argv[2]
  13. import sys
  14. import os
  15. import re
  16. # from smtplib import SMTP_SSL as SMTP
  17. from smtplib import SMTP
  18. from email.MIMEText import MIMEText
  19. try:
  20.     msg = MIMEText(content, text_subtype)
  21.     msg['Subject'] = subject
  22.     msg['From'] = sender
  23.     conn = SMTP(SMTPserver)
  24.     conn.ehlo()
  25.     conn.starttls()
  26.     conn.ehlo()
  27.     conn.set_debuglevel(False)
  28.     conn.login(USERNAME, PASSWORD)
  29.     try:
  30.         conn.sendmail(sender, destination, msg.as_string())
  31.     finally:
  32.         conn.close()
  33.  
  34. except Exception, exc:
  35.     sys.exit( "mail failed; %s" %str(exc) )
Advertisement
Add Comment
Please, Sign In to add comment