jump to navigation

Send e-mail through gmail using python October 5, 2007

Posted by bdonovan in : Uncategorized , trackback

I’ve been running a number of simulations on a remote machine which take days to complete. I got tired to sshing into the machine to check the status so I’ve written a short python script to send a notification e-mail through gmail.

#!/usr/bin/env python

import smtplib
import sys

smtpserver = 'smtp.gmail.com'
user = ''
passwd = ''
subject = 'Processing Complete'

def send_gmail(to,msg):
    conn = smtplib.SMTP(smtpserver)
    msg = 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' % \


if __name__ == '__main__':
    to = sys.argv[1]
    msg = sys.argv[2]

The script can be run from the command line:

# send_gmail.py to@address.com 'Msg'


Sorry comments are closed for this entry