[Tutor] Smtplib module

Sheila King sheila@thinkspot.net
Sat, 20 Oct 2001 15:00:22 -0700


On Sat, 20 Oct 2001 23:41:34 +0200, "A" <export@bmatrading.com>  wrote
about [Tutor] Smtplib module:

:Hi,
:I want to use smtplib module for sending emails.
:Is there any way how I can test a return code, generated by this 
:module, to see if an email was accepting for delivery, for example?
:Thank you for help.

Sure.

import smtplib

message = """\
To: me@mydomain.com
From: me@mydomain.com
Subject: testing smtp response
Date: Sat, Oct 20 2001 15:00 -0700

Here is the message body.
"""

SENDER = 'me@mydomain'
RECIPIENT = 'me@mydomain'

server = smtplib.SMTP('localhost')
response = server.sendmail(SENDER, RECIPIENT, message)
server.close()

print response


# I think the above code is correct, but I didn't test-run it.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/