sending emails using python
Sybren Stuvel
sybrenUSE at YOURthirdtower.com.imagination
Thu Sep 7 03:21:13 EDT 2006
sridhar enlightened us with:
> iam having user account on an exchangeserver.
> with that can i send an email using python?
>
> if iam using the following code iam getting error
>
>
> fromAddress = 'sridhar_kasturi at satyam.com'
> toAddress = 'sridhar_kasturi at satyam.com'
> msg = "Subject: Hello\n\nThis is the body of the message."
^^^^
You need \r\n\r\n there. Line-ends in email messages should be DOS
line-ends.
> Traceback (most recent call last):
> File
> "C:\sridhar\Beginning_Python\Beginning_Python\Chapter16\tryitout\InitialMailExample.py",
> line 5, in ?
> server = smtplib.SMTP("hstmsg002",25)
> File "C:\Python24\lib\smtplib.py", line 244, in __init__
> (code, msg) = self.connect(host, port)
> File "C:\Python24\lib\smtplib.py", line 307, in connect
> (code, msg) = self.getreply()
> File "C:\Python24\lib\smtplib.py", line 351, in getreply
> raise SMTPServerDisconnected("Connection unexpectedly closed")
> SMTPServerDisconnected: Connection unexpectedly closed
Well that's useless. You could install a network sniffer
(http://www.ethereal.com/) and find out what's actually sent over the
network connection, and where things go wrong.
Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
More information about the Python-list
mailing list