m0n0lithic icon

smtp.py

m0n0lithic | PRO | 05/14/15 03:47:04 PM UTC | 0 ⭐ | 439 👁️ | Never ⏰ | []
Python |

930 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/env python
from sys import argv
SMTPserver = '172.25.1.63'
sender = '[SPOA::DIMAR-CIOH] <[email protected]>'
destination = ['[email protected]','[email protected]','[email protected]']
USERNAME = "WilderXXXXXXn"
PASSWORD = "WNCPXXXXX"
text_subtype = 'plain'
# content="""\
# Test Test Test
# """
content = argv[1]
subject = "::. SPOA Status .:: " + argv[2]
import sys
import os 
import re 
# from smtplib import SMTP_SSL as SMTP
from smtplib import SMTP
from email.MIMEText import MIMEText
try:
    msg = MIMEText(content, text_subtype)
    msg['Subject'] = subject
    msg['From'] = sender
    conn = SMTP(SMTPserver)
    conn.ehlo()
    conn.starttls()
    conn.ehlo()
    conn.set_debuglevel(False)
    conn.login(USERNAME, PASSWORD)
    try:
        conn.sendmail(sender, destination, msg.as_string())
    finally:
        conn.close()
 
except Exception, exc:
    sys.exit( "mail failed; %s" %str(exc) )

Comments