#! /usr/local/bin/python SMTPserver = 'outgoing.verizon.net' sender = 'davebodnar@verizon.net' destination = ['bodnar@gmail.com'] USERNAME = "davebodnar" PASSWORD = "pwpwpwpwpw" # typical values for text_subtype are plain, html, xml text_subtype = 'plain' filename="ipnow.txt" tfile=open(filename) ipnow=tfile.read() content="""\ Test message """ newip= '244.244.244.12' print ipnow subject = ipnow #"Sent from Python" import sys import os import re from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL) # from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption) from email.MIMEText import MIMEText try: msg = MIMEText(content, text_subtype) msg['Subject']= subject msg['From'] = sender # some SMTP servers will do this automatically, not all conn = SMTP(SMTPserver) 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) ) # give a error message