thanks a whole bunch !
shawn
On 7/31/06, Justin Ezequiel <[EMAIL PROTECTED]> wrote:
When I first started with Python, I used MimeWriter to create E-mails.
Then some mail servers rejected my E-mails.
Some research (google) indicated (to me) that I needed a MIME-Version header.
(Can't recall now if I also needed a Content-Type header.)
Anyway, more research (Python docs) indicated that I should use the
email package instead.
I have been doing so since and have not had reports of anymore rejected E-mails.
Hope this helps.
>>> import email
>>> from email.MIMENonMultipart import MIMENonMultipart
>>> from email.Utils import formataddr
>>> format_addresses = lambda pairs: ', '.join([formataddr(pair) for
pair in pairs])
>>> msg = MIMENonMultipart('text', 'plain', charset='us-ascii')
>>> msg.set_payload('Foo Bar')
>>> msg.add_header('From', formataddr(('Justin', '[EMAIL PROTECTED]')))
>>> msg.add_header('To', format_addresses([('Justin', '[EMAIL PROTECTED]'),
('You', '[EMAIL PROTECTED]')]))
>>> print msg.as_string()
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
From: Justin <[EMAIL PROTECTED]>
To: Justin <[EMAIL PROTECTED]>, You <[EMAIL PROTECTED]>
Foo Bar
>>>
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor