On Wednesday 12 November 2008 06:25:53 pm Girish Venkatachalam wrote:
> I just finished it in perl. My python skills are very bad.
>
> Here is a way to achieve it in perl.

In python (most of this shamelessly copied from a google search):

#!/usr/bin/env python
import smtplib

def mail(serverURL=None, sender='', to='', subject='', text=''):
    """
    Usage:
    
mail('somemailserver.com', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'test', 
'This 
is a test')
    """
    headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (sender, to, 
subject)
    message = headers + text
    mailServer = smtplib.SMTP(serverURL)
    mailServer.sendmail(sender, to, message)
    mailServer.quit()


serverURL = 'mail.foo.com'
sender = '[EMAIL PROTECTED]'
subject = 'hi there'
text = 'some text'    
f = open('addresses.txt','r')
for address in f.readlines():
  mail(serverURL=serverURL,sender=sender,to=address,subject=subject,text=text)
  print "Mail sent to %s" %address
f.close()


-- 
regards
KG
http://lawgon.livejournal.com
_______________________________________________
To unsubscribe, email [EMAIL PROTECTED] with 
"unsubscribe <password> <address>"
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to