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 = 's**************@satyam.com'
toAddress = 's**************@satyam.com'
msg = "Subject: Hello\n\nThis is the body of the message."
import smtplib
server = smtplib.SMTP("hstmsg002",25)
server.sendmail(fromAddress, toAddress, msg)
error:
Traceback (most recent call last):
File
"C:\sridhar\Beginning_Python\Beginning_Python\Chap ter16\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 14 9817
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 = 's**************@satyam.com'
toAddress = 's**************@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\Chap ter16\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/
On 07/09/06, Sybren Stuvel <sy*******@yourthirdtower.com.imaginationwrote:
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
Traceback (most recent call last):
File
"C:\sridhar\Beginning_Python\Beginning_Python\Chap ter16\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.
Have you verified that you are allowed to use SMTP on this server ?
Can you send email via it using outlook express or a similar POP3/IMAP
mail client?
:)
Sybren Stuvel wrote:
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 = 's**************@satyam.com' toAddress = 's**************@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.
This is untrue for the Python smtplib, though correct according to the
RFCs. The SMTP.data() method uses a locally-declared function called
quotedata() to ensure the correct line endings, so using "\n" will
result in the same message as using "\r\n".
>
>>Traceback (most recent call last): File "C:\sridhar\Beginning_Python\Beginning_Python\Ch apter16\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.
Useless it might be, but it's a lot more clueful than some questions we
see, so it seems a little dismissive just to say "it's useless" - the OP
has provided the traceback, which is so often missing in questions from
newbies, and has correctly localized the error to a small chunk of code.
True, the error message isn't particularly helpful in these
circumstances, but it probably represents an accurate description (from
the client's point of view) about what's happening, in which case an
Ethereal trace will provide little more data than the traceback. I
suppose it'll tell you whether the server is sending RST or FIN to
terminate the connection, but it won't give much insight into why.
We might hazard a guess that the connection is being closed because
there is no SMTP server running on the named host, or (less likely) it
requires authentication. Unfortunately when I try to connect to a
non-existent SMTP server on an existent host I see
socket.error: (113, 'Software caused connection abort')
under both 2.4.3 and 2.5b2. Alas I don't have ready access to a server
that requires authentication (my servers authenticate senders by POP
access IIRC). So I can't reproduce this error.
Perhaps the SMTP server is strapped down to accepting connections from
specific IP addresses by some firewall? It would probably be a good idea
to have a chat with the server's administrator to see if they can
suggest what might be going wrong.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
sridhar wrote:
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 = 's**************@satyam.com'
toAddress = 's**************@satyam.com'
msg = "Subject: Hello\n\nThis is the body of the message."
import smtplib
server = smtplib.SMTP("hstmsg002",25)
server.sendmail(fromAddress, toAddress, msg)
Do yourself a favor and use the email module to construct your messages
with. Constructing messages by hand can lead you into so many traps.
Especially if you are using international characters in you messages.
--
hilsen/regards Max M, Denmark http://www.mxm.dk/
IT's Mad Science
Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96
Max M wrote:
sridhar wrote:
>>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 = 's**************@satyam.com' toAddress = 's**************@satyam.com' msg = "Subject: Hello\n\nThis is the body of the message." import smtplib server = smtplib.SMTP("hstmsg002",25) server.sendmail(fromAddress, toAddress, msg)
Do yourself a favor and use the email module to construct your messages
with. Constructing messages by hand can lead you into so many traps.
Especially if you are using international characters in you messages.
Good advice. However, since the error is occurring in the SMTP() call a
malformed message is clearly not the cause of this particular problem.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Steve Holden enlightened us with:
This is untrue for the Python smtplib, though correct according to
the RFCs. The SMTP.data() method uses a locally-declared function
called quotedata() to ensure the correct line endings, so using "\n"
will result in the same message as using "\r\n".
Ah, wonderful.
Useless it might be, but it's a lot more clueful than some questions
we see, so it seems a little dismissive just to say "it's useless" -
the OP has provided the traceback, which is so often missing in
questions from newbies, and has correctly localized the error to a
small chunk of code.
I agree with you. My remark might indeed have sounded harsher than
intended. It referred to the traceback itself, not the posting of the
traceback. That was rather useful.
Ethereal trace will provide little more data than the traceback.
I don't know until I see it. Perhaps the socket is closed in response
to something the client sends. That can be seen in the Ethereal trace.
I suppose it'll tell you whether the server is sending RST or FIN to
terminate the connection, but it won't give much insight into why.
A quick peek in the SMTP logfiles should tell you that.
Perhaps the SMTP server is strapped down to accepting connections from
specific IP addresses by some firewall?
In that case I'd expect the SMTP server to simply ignore the
connection attempt and cause a timeout in the connecting phase. I
wouldn't expect a connection to be created and then closed again,
which is what I read in the posted traceback.
It would probably be a good idea to have a chat with the server's
administrator to see if they can suggest what might be going wrong.
Good idea indeed. Another idea would be to use something like netcat
or telnet to connect to the port and see what happens if you manually
type an SMTP connection.
Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
Tim Williams enlightened us with:
Can you send email via it using outlook express or a similar
POP3/IMAP mail client?
Wouldn't you use a SMTP client to send email?
Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
On 07/09/06, Sybren Stuvel <sy*******@yourthirdtower.com.imaginationwrote:
Tim Williams enlightened us with:
Can you send email via it using outlook express or a similar
POP3/IMAP mail client?
Wouldn't you use a SMTP client to send email?
Outlook Express *is* a mail client that uses SMTP as the outbound protocol.
:)
On 2006-09-07, Sybren Stuvel <sy*******@YOURthirdtower.com.imaginationwrote:
Tim Williams enlightened us with:
>Can you send email via it using outlook express or a similar POP3/IMAP mail client?
Wouldn't you use a SMTP client to send email?
I would, but I don't use exchange server. :)
The one exchange server I used in the past didn't accept SMTP
mail.
--
Grant Edwards grante Yow! I have the power
at to HALT PRODUCTION on all
visi.com TEENAGE SEX COMEDIES!!
On 07/09/06, Hari Sekhon <hp******@googlemail.comwrote:
>
Grant Edwards wrote:
On 2006-09-07, Sybren Stuvel
<sy*******@YOURthirdtower.com.imaginationwrote:
Tim Williams enlightened us with:
Can you send email via it using outlook express or a similar
POP3/IMAP mail client?
Wouldn't you use a SMTP client to send email?
I would, but I don't use exchange server. :)
The one exchange server I used in the past didn't accept SMTP
mail.
errr, I used to admin Exchange, if it does accept SMTP then how could it
function as a live mail server?
Did you mean *doesn't accept* ??
There are a couple of possibilities at least, of the top of my head:
* The IMC / IMS (smtp connector) is located on a different server
within its Exchange organisation, or a DMZ'ed exchange server that is
only used for SMTP.
* The server doesn't accept SMTP from local IP ranges, only from
external (ie inbound email)
Outlook / Exchange clients use MAPI, internal SMTP is only a
requirement if you have non-MAPI clients sending email through the
server.
HTH :)
On 2006-09-07, Tim Williams <ti*@tdw.netwrote:
> Wouldn't you use a SMTP client to send email?
I would, but I don't use exchange server. :)
The one exchange server I used in the past didn't accept SMTP mail.
errr, I used to admin Exchange, if it does accept SMTP then how could it function as a live mail server?
Did you mean *doesn't accept* ??
One presumes he did.
There are a couple of possibilities at least, of the top of my
head:
* The IMC / IMS (smtp connector) is located on a different
server within its Exchange organisation, or a DMZ'ed
exchange server that is only used for SMTP.
* The server doesn't accept SMTP from local IP ranges, only
from external (ie inbound email)
I believe it was the latter. I'm pretty sure there was only
one server. When I first started at that company it did accept
SMTP connections on it's internal network interface.
Outlook / Exchange clients use MAPI, internal SMTP is only a
requirement if you have non-MAPI clients sending email through
the server.
And BOFH was horrified by non-MS software, so he shut off IMAP
support and SMTP support on the internal network as a way to
force everybody to switch to Outlook.
--
Grant Edwards grante Yow! This ASEXUAL
at PIG really BOILS
visi.com my BLOOD... He's
so... so... URGENT!!
Tim Williams wrote:
On 07/09/06, Sybren Stuvel <sy*******@yourthirdtower.com.imaginationwrote:
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
>
Traceback (most recent call last):
File
"C:\sridhar\Beginning_Python\Beginning_Python\Chap ter16\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.
Have you verified that you are allowed to use SMTP on this server ?
Can you send email via it using outlook express or a similar POP3/IMAP
mail client?
:)
yes , because iam having account on that server
On 14 Sep 2006 00:11:05 -0700, sridhar <ra*****************@gmail.comwrote:
>
Tim Williams wrote:
Have you verified that you are allowed to use SMTP on this server ?
Can you send email via it using outlook express or a similar POP3/IMAP
mail client?
:)
yes , because iam having account on that server
Having an account on an Exchange server doesn't automatically mean you
have SMTP access to that server. Some exchange servers don't have
SMTP running at all, and others will not allow SMTP access from local
IP addresses - even with authentication.
Can you telnet to your Exchange server on port 25 and start an SMTP
conversation, using the EHLO or HELO, MAIL and RCPT commands, but
quitting before the DATA command? If you can successfully specify a
recipient, then your script should work, if not you will need your
script to work around the problem based on what you do or don't get
back from the server.
HTH :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Arek |
last post by:
Hey,
I have a question, what are the possibilities of sending emails using
ASP.net. (and VB.net)
What I think is that user can send automatic reminder if he check box on
the form and submit. Do...
|
by: A |
last post by:
Hi all!
I would like to ask a question on sending emails...
I have a web application that requires sending emails using email templates.
The templates that I've made are separate HTML files...
|
by: Nicole |
last post by:
I found this code below to use to send emails using VB with Outlook.
However, it gives these errors.
'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and...
|
by: aroraamit81 |
last post by:
Hi,
I am using CDO component to send emails through my ASP page as I am
having IIS on windows XP..........
Now the mails goes and gets into mailroot\Queue folder but does not
reaches to the...
|
by: Maxelcat |
last post by:
HI
I am really confused (and getting a bit stressed!!!)
I want to send email from a form on the website I am developing. I have to
use .asp (the host server doesn't have .net)
After many...
|
by: lizii |
last post by:
Hey there - hopefully last newbie question i will ask for a while!
I want my application to work where you click a button - and it either:
a) open a email application - insert the correct email...
|
by: damimkader |
last post by:
Hi,
I'm trying to send emails using a Macro based on an Excel Sheet and the Email Client I'm using is Lotus Notes.
OS used - Windows Xp.
Language - VB
Below is the Code I'm using for doing...
|
by: Ali Rizwan |
last post by:
Hi all,
How can i send email to any email address using a specific email address or unknown email address.... Email may contain some attachments.....
Thanx
>> ALI <<
|
by: Bernhard Walle |
last post by:
Hi,
* cindy jones :
Following (tested) snippet should help:
------------------ 8< ------------------------------
from smtplib import SMTP
from email.mime.image import MIMEImage
from...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |