On 09:45:38 Nov 13, Kenneth Gonsalves wrote:
> In python (most of this shamelessly copied from a google search):
>
Never mind. I do copy paste all the time. ;)
As long as we know what we are doing it is not wrong at all, in fact it
is most desirable.
We are simply following Newton's quote "I could see farther since I
stood on the shoulders of giants gone before me. " ;)
> #!/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()
Nice. It helps me refresh my lost python skills. ;)
However this approach assumes that you operate in 'smart mode of SMTP
sending'.
Not a very nice thing to do. Hence the need to specify the SMTP server.
Whereas my approach relies on the machine being properly setup for mail
sending by acting as a full blown SMTP MTA.
I am also unable to find out where you are parsing the file to fish out
the individual addresses from a comma separated list.
I thought that was your main question.
Anyway let us move on.
Have a nice day!
Best,
-Girish
_______________________________________________
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