473,770 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending emails using python

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("h stmsg002",25)
server.sendmail (fromAddress, toAddress, msg)

error:

Traceback (most recent call last):
File
"C:\sridhar\Beg inning_Python\B eginning_Python \Chapter16\tryi tout\InitialMai lExample.py",
line 5, in ?
server = smtplib.SMTP("h stmsg002",25)
File "C:\Python24\li b\smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "C:\Python24\li b\smtplib.py", line 307, in connect
(code, msg) = self.getreply()
File "C:\Python24\li b\smtplib.py", line 351, in getreply
raise SMTPServerDisco nnected("Connec tion unexpectedly closed")
SMTPServerDisco nnected: Connection unexpectedly closed

Sep 7 '06
14 9902
On 07/09/06, Hari Sekhon <hp******@googl email.comwrote:
>
Grant Edwards wrote:
On 2006-09-07, Sybren Stuvel
<sy*******@YOUR thirdtower.com. imaginationwrot e:
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 :)
Sep 7 '06 #11
On 2006-09-07, Tim Williams <ti*@tdw.netwro te:
> 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!!
Sep 7 '06 #12
Hari Sekhon wrote:
[...]
>
BOFH?
Bas**rd Operator From Hell
lol
Indeed.

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

Sep 7 '06 #13

Tim Williams wrote:
On 07/09/06, Sybren Stuvel <sy*******@your thirdtower.com. imaginationwrot e:
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\Beg inning_Python\B eginning_Python \Chapter16\tryi tout\InitialMai lExample.py",
line 5, in ?
server = smtplib.SMTP("h stmsg002",25)
File "C:\Python24\li b\smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "C:\Python24\li b\smtplib.py", line 307, in connect
(code, msg) = self.getreply()
File "C:\Python24\li b\smtplib.py", line 351, in getreply
raise SMTPServerDisco nnected("Connec tion unexpectedly closed")
SMTPServerDisco nnected: 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

Sep 14 '06 #14
On 14 Sep 2006 00:11:05 -0700, sridhar <ra************ *****@gmail.com wrote:
>
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 :)
Sep 14 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
394
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 I need to have SMTP server? Can it be done without using of SMTP, something similar to automation in VB? I tried before for quite a few days to automate generating word documents and finally I gave up, so I would like to know before I start...
3
1593
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 and would require some data based on what the user has entered. Please help!!!
4
4573
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 'Outlook.ItemEvents_Event'. Name 'olByReference' is not declared. Name 'olMailItem' is not declared. Name 'olTo' is not declared. How could i edit this code to get it to work?
4
3752
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 destination........ Pls tell me what do I need to do......... here goes my code for your reference.....
2
1249
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 hours I have got as far as this code:
3
1551
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 address and add a subject + any attachments or b) just create an email and send it off with appropriate attachments etc.
0
1780
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 the same. Dim Maildb As Object
1
1515
Ali Rizwan
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 <<
0
1292
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 email.mime.text import MIMEText
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.