smtp module - specifying multiple email recipients?

Alex Hunsley lard at tardis.ed.ac.molar.uk
Thu Jul 1 08:45:50 EDT 2004


I'm using the smtp module to send emails from python.
I would like to specify several recipients of the email like follows:

        msg = MIMEText(time.ctime("Body text of email")

        me = 'my at sending.address'
        you = 'recipient1 at some.where,recipient2 at some.where'
        msg['Subject'] = '*** Carwatch alert'
        msg['From'] = me
        msg['To'] = you

        # Send the message via our own SMTP server, but don't include the
        # envelope header.
        #    s = smtplib.SMTP('smtp.ednet.co.uk')
        s = smtplib.SMTP('192.168.1.105')
        # s.connect()
        s.sendmail(me, [you], msg.as_string())

.. when I execute this code, only recipient1 at some.where gets the email. 
Is there a way to specifiy multiple addresses in the To field?

thanks
alex




More information about the Python-list mailing list