This works for me... def SendEmail(msgType,sender,recipient,subject,message): """ Sends either a log file or a string message in email to recipient. Uses Google smtp server to send the mail.
CHANGELOG: 2006-12-7: Set sender, recipient, subject as input variables --------------------------------------------------------------------------------------------- Inputs: msgType: If 'log', message is path to log file that is to be written into email body sender: Senders email addy recipient: Who we want to send to subject: Email subject line message: Message body of email --------------------------------------------------------------------------------------------- """ # determine msg type if msgType == 'log': # Send log file in email fp = open(message, 'rb') # Create a text/plain message # Read contents of log file into memory msg = MIMEText(fp.read()) fp.close() else: # If not a log file, just create a text/plain message msg = MIMEText(message) # User/pwd me = '[EMAIL PROTECTED]' pwd = 'pass' # Build the email fromAddr = sender toAddr = recipient msg['Subject'] = subject msg['From'] = fromAddr msg['To'] = toAddr # Set up and connect to smtp server server = smtplib.SMTP('smtp.gmail.com', 587) server.set_debuglevel(1) server.ehlo() server.starttls() server.ehlo() server.login(me, pwd) # Send the email server.sendmail(fromAddr, toAddr, msg.as_string()) server.close() -- http://mail.python.org/mailman/listinfo/python-list