Python, Unix sendmail, and multiple recipients

Skip Montanaro skip at pobox.com
Tue Oct 16 12:08:17 EDT 2001


    Randy> Can anyone give me an example of how to invoke the Unix sendmail
    Randy> in Python, and send an email message to more then one recipient
    Randy> (two people, for example)?

How about:

    fwd = os.popen('/usr/sbin/sendmail -odb -t', 'w')
    fwd.write('To: skip at mojam.com\n')
    fwd.write('To: Randy.L.Kemp at motorola.com\n')
    fwd.write('Subject: Hey there!\n')
    fwd.write('\n')
    fwd.writelines(body)

where "body" is a list of newline-terminated strings.

Any particular reason why you don't want to use smtplib?

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list