Merge pull request #2 from TJM/master
CentOS 5 (Python 2.4) compatible import and changing from MIMEMultipart -> MIMEText
This commit is contained in:
commit
6a18959e75
@ -15,7 +15,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
import smtplib, email
|
import smtplib
|
||||||
|
|
||||||
|
try: from email.mime.text import MIMEText
|
||||||
|
except ImportError:
|
||||||
|
# Python 2.4 (CentOS 5.x)
|
||||||
|
from email.MIMEText import MIMEText
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
@ -93,14 +98,11 @@ def main(argv):
|
|||||||
|
|
||||||
def send_notification(from_email, to_email, subject, message, smtp_server,
|
def send_notification(from_email, to_email, subject, message, smtp_server,
|
||||||
smtp_port, use_ssl, use_auth, smtp_user, smtp_pass):
|
smtp_port, use_ssl, use_auth, smtp_user, smtp_pass):
|
||||||
msg = email.MIMEMultipart.MIMEMultipart()
|
msg = MIMEText(message)
|
||||||
body = email.MIMEText.MIMEText(message)
|
|
||||||
|
|
||||||
msg.attach(body)
|
msg['From'] = from_email
|
||||||
|
msg['To'] = ', '.join(to_email)
|
||||||
msg.add_header('From', from_email)
|
msg['Subject'] = subject
|
||||||
msg.add_header('To', ', '.join(to_email))
|
|
||||||
msg.add_header('Subject', subject)
|
|
||||||
|
|
||||||
if(use_ssl):
|
if(use_ssl):
|
||||||
mailer = smtplib.SMTP_SSL(smtp_server, smtp_port)
|
mailer = smtplib.SMTP_SSL(smtp_server, smtp_port)
|
||||||
|
Loading…
Reference in New Issue
Block a user