473,706 Members | 3,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem occured while sending mail

sui
this is my code

import sys, os, glob, datetime, time
import smtplib
## Parameters for SMTP session
port=587
SMTPserver= 'smtp.gmail.com '
SMTPuser= '...@gmail.com'
pw= 'fill in here'
SENDER= SMTPuser

## Message details
FROM= SENDER
TO= 'notgm...@a.com '
CC=FROM
##RECEIVERS= (TO, CC) ##proper way to send to both TO and CC
RECEIVERS= (TO,) ## ignore the CC address

subject= 'Test 1a'
message='*** Email test *** '

print 'Starting SMTP mail session on %s as %s ' %
(SMTPserver,SMT Puser)
session = smtplib.SMTP(SM TPserver,port)
session.set_deb uglevel(0) # set debug level to 1 to see details
session.ehlo(SM TPuser) # say hello
session.starttl s() # TLS needed
session.ehlo(SM TPuser) # say hello again, not sure why
session.login(S MTPuser, pw)

##Create HEADER + MESSAGE
HEADER= 'From: %s\r\n' % FROM
HEADER= HEADER + 'To: %s\r\n' % TO
HEADER= HEADER + 'Cc: %s\r\n' % CC
HEADER= HEADER + 'Subject: %s\r\n' % subject
BODY= HEADER + '\r\n' + message
print BODY

SMTPresult = session.sendmai l(SENDER, RECEIVERS, BODY) ## send email

session.close()

Now when i run this .py file...as python mail.py
i can see only statement
starting smtp mail......n details
then nothing on screen after few minutes or after pressing ctrl +c
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.conne ct(sa)
File "<string>", line 1, in connect
or may be conncetion time out

wats the solution for this
Sep 17 '08 #1
5 3119
sui
On Sep 17, 5:04 pm, sui <gogtesuy...@gm ail.comwrote:
this is my code

import sys, os, glob, datetime, time
import smtplib
## Parameters for SMTP session
port=587
SMTPserver= 'smtp.gmail.com '
SMTPuser= '...@gmail.com'
pw= 'fill in here'
SENDER= SMTPuser

## Message details
FROM= SENDER
TO= 'notgm...@a.com '
CC=FROM
##RECEIVERS= (TO, CC) ##proper way to send to both TO and CC
RECEIVERS= (TO,) ## ignore the CC address

subject= 'Test 1a'
message='*** Email test *** '

print 'Starting SMTP mail session on %s as %s ' %
(SMTPserver,SMT Puser)
session = smtplib.SMTP(SM TPserver,port)
session.set_deb uglevel(0) # set debug level to 1 to see details
session.ehlo(SM TPuser) # say hello
session.starttl s() # TLS needed
session.ehlo(SM TPuser) # say hello again, not sure why
session.login(S MTPuser, pw)

##Create HEADER + MESSAGE
HEADER= 'From: %s\r\n' % FROM
HEADER= HEADER + 'To: %s\r\n' % TO
HEADER= HEADER + 'Cc: %s\r\n' % CC
HEADER= HEADER + 'Subject: %s\r\n' % subject
BODY= HEADER + '\r\n' + message
print BODY

SMTPresult = session.sendmai l(SENDER, RECEIVERS, BODY) ## send email

session.close()

Now when i run this .py file...as python mail.py
i can see only statement
starting smtp mail......n details
then nothing on screen after few minutes or after pressing ctrl +c
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.conne ct(sa)
File "<string>", line 1, in connect
or may be conncetion time out

wats the solution for this
if i dont press cntrl + c then it shows
Starting SMTP mail session on smtp.gmail.com as go*********@gma il.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 310, in connect
raise socket.error, msg
socket.error: (110, 'Connection timed out')

plz help me its urgent.....i want to complete it as early as possible
Sep 17 '08 #2
On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <go*********@gm ail.comwrote:
On Sep 17, 5:04 pm, sui <gogtesuy...@gm ail.comwrote:
>this is my code

import sys, os, glob, datetime, time
import smtplib
## Parameters for SMTP session
port=587
SMTPserver= 'smtp.gmail.com '
SMTPuser= '...@gmail.com'
pw= 'fill in here'
SENDER= SMTPuser

## Message details
FROM= SENDER
TO= 'notgm...@a.com '
CC=FROM
##RECEIVERS= (TO, CC) ##proper way to send to both TO and CC
RECEIVERS= (TO,) ## ignore the CC address

subject= 'Test 1a'
message='*** Email test *** '

print 'Starting SMTP mail session on %s as %s ' %
(SMTPserver,SM TPuser)
session = smtplib.SMTP(SM TPserver,port)
session.set_de buglevel(0) # set debug level to 1 to see details
session.ehlo(S MTPuser) # say hello
session.startt ls() # TLS needed
session.ehlo(S MTPuser) # say hello again, not sure why
session.login( SMTPuser, pw)

##Create HEADER + MESSAGE
HEADER= 'From: %s\r\n' % FROM
HEADER= HEADER + 'To: %s\r\n' % TO
HEADER= HEADER + 'Cc: %s\r\n' % CC
HEADER= HEADER + 'Subject: %s\r\n' % subject
BODY= HEADER + '\r\n' + message
print BODY

SMTPresult = session.sendmai l(SENDER, RECEIVERS, BODY) ## send email

session.close( )

Now when i run this .py file...as python mail.py
i can see only statement
starting smtp mail......n details
then nothing on screen after few minutes or after pressing ctrl +c
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.conne ct(sa)
File "<string>", line 1, in connect
or may be conncetion time out

wats the solution for this

if i dont press cntrl + c then it shows
Starting SMTP mail session on smtp.gmail.com as go*********@gma il.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 310, in connect
raise socket.error, msg
socket.error: (110, 'Connection timed out')

plz help me its urgent.....i want to complete it as early as possible
I pasted your code into a file named temp.py,
and (perhaps superstitiously ) added a backslash to this line:
>print 'Starting SMTP mail session on %s as %s ' %
Here's what it does (long line wrapped manually):

peter@eleodes:~ $ python temp.py
Starting SMTP mail session on smtp.gmail.com as ...@gmail.com
Traceback (most recent call last):
File "temp.py", line 27, in ?
session.login(S MTPuser, pw)
File "/usr/lib/python2.4/smtplib.py", line 591, in login
raise SMTPAuthenticat ionError(code, resp)
smtplib.SMTPAut henticationErro r: (535, \
'5.7.1 Username and Password not accepted. Learn more at\n' \
'5.7.1 http://mail.google.com/support/bin/answer.py?answe r=' \
'14257 a8sm34686663poa .12')
peter@eleodes:~ $

This indicates that it got much farther than when you ran it, since
your timeout message comes from the smtplib.SMTP call several lines
before the session.login call.

As a simple connectivity test, you might see whether you can connect
using telnet:

peter@eleodes:~ $ telnet smtp.gmail.com 587
Trying 72.14.253.109.. .
Connected to gmail-smtp.l.google.c om.
Escape character is '^]'.
220 mx.google.com ESMTP m27sm34789033po f.6
^]c

telnetc
Connection closed.
peter@eleodes:~ $

--
To email me, substitute nowhere->spamcop, invalid->net.
Sep 17 '08 #3
sui
On Sep 17, 8:04 pm, Peter Pearson <ppear...@nowhe re.invalidwrote :
On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <gogtesuy...@gm ail.comwrote:
On Sep 17, 5:04 pm, sui <gogtesuy...@gm ail.comwrote:
this is my code
import sys, os, glob, datetime, time
import smtplib
## Parameters for SMTP session
port=587
SMTPserver= 'smtp.gmail.com '
SMTPuser= '...@gmail.com'
pw= 'fill in here'
SENDER= SMTPuser
## Message details
FROM= SENDER
TO= 'notgm...@a.com '
CC=FROM
##RECEIVERS= (TO, CC) ##proper way to send to both TO and CC
RECEIVERS= (TO,) ## ignore the CC address
subject= 'Test 1a'
message='*** Email test *** '
print 'Starting SMTP mail session on %s as %s ' %
(SMTPserver,SMT Puser)
session = smtplib.SMTP(SM TPserver,port)
session.set_deb uglevel(0) # set debug level to 1 to see details
session.ehlo(SM TPuser) # say hello
session.starttl s() # TLS needed
session.ehlo(SM TPuser) # say hello again, not sure why
session.login(S MTPuser, pw)
##Create HEADER + MESSAGE
HEADER= 'From: %s\r\n' % FROM
HEADER= HEADER + 'To: %s\r\n' % TO
HEADER= HEADER + 'Cc: %s\r\n' % CC
HEADER= HEADER + 'Subject: %s\r\n' % subject
BODY= HEADER + '\r\n' + message
print BODY
SMTPresult = session.sendmai l(SENDER, RECEIVERS, BODY) ## send email
session.close()
Now when i run this .py file...as python mail.py
i can see only statement
starting smtp mail......n details
then nothing on screen after few minutes or after pressing ctrl +c
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.conne ct(sa)
File "<string>", line 1, in connect
or may be conncetion time out
wats the solution for this
if i dont press cntrl + c then it shows
Starting SMTP mail session on smtp.gmail.com as gogtesuy...@gma il.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 310, in connect
raise socket.error, msg
socket.error: (110, 'Connection timed out')
plz help me its urgent.....i want to complete it as early as possible

I pasted your code into a file named temp.py,
and (perhaps superstitiously ) added a backslash to this line:
print 'Starting SMTP mail session on %s as %s ' %

Here's what it does (long line wrapped manually):

peter@eleodes:~ $ python temp.py
Starting SMTP mail session on smtp.gmail.com as ....@gmail.com
Traceback (most recent call last):
File "temp.py", line 27, in ?
session.login(S MTPuser, pw)
File "/usr/lib/python2.4/smtplib.py", line 591, in login
raise SMTPAuthenticat ionError(code, resp)
smtplib.SMTPAut henticationErro r: (535, \
'5.7.1 Username and Password not accepted. Learn more at\n' \
'5.7.1http://mail.google.com/support/bin/answer.py?answe r='\
'14257 a8sm34686663poa .12')
peter@eleodes:~ $

This indicates that it got much farther than when you ran it, since
your timeout message comes from the smtplib.SMTP call several lines
before the session.login call.

As a simple connectivity test, you might see whether you can connect
using telnet:

peter@eleodes:~ $ telnet smtp.gmail.com 587
Trying 72.14.253.109.. .
Connected to gmail-smtp.l.google.c om.
Escape character is '^]'.
220 mx.google.com ESMTP m27sm34789033po f.6
^]c

telnetc
Connection closed.
peter@eleodes:~ $

--
To email me, substitute nowhere->spamcop, invalid->net.
Actually i m working at place where proxy server has been
working......so is it problem caused by that proxy server..peter thnks
for suggestion but still its not working......
Sep 18 '08 #4
sui
On Sep 17, 8:04 pm, Peter Pearson <ppear...@nowhe re.invalidwrote :
On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <gogtesuy...@gm ail.comwrote:
On Sep 17, 5:04 pm, sui <gogtesuy...@gm ail.comwrote:
this is my code
import sys, os, glob, datetime, time
import smtplib
## Parameters for SMTP session
port=587
SMTPserver= 'smtp.gmail.com '
SMTPuser= '...@gmail.com'
pw= 'fill in here'
SENDER= SMTPuser
## Message details
FROM= SENDER
TO= 'notgm...@a.com '
CC=FROM
##RECEIVERS= (TO, CC) ##proper way to send to both TO and CC
RECEIVERS= (TO,) ## ignore the CC address
subject= 'Test 1a'
message='*** Email test *** '
print 'Starting SMTPmailsession on %s as %s ' %
(SMTPserver,SMT Puser)
session = smtplib.SMTP(SM TPserver,port)
session.set_deb uglevel(0) # set debug level to 1 to see details
session.ehlo(SM TPuser) # say hello
session.starttl s() # TLS needed
session.ehlo(SM TPuser) # say hello again, not sure why
session.login(S MTPuser, pw)
##Create HEADER + MESSAGE
HEADER= 'From: %s\r\n' % FROM
HEADER= HEADER + 'To: %s\r\n' % TO
HEADER= HEADER + 'Cc: %s\r\n' % CC
HEADER= HEADER + 'Subject: %s\r\n' % subject
BODY= HEADER + '\r\n' + message
print BODY
SMTPresult = session.sendmai l(SENDER, RECEIVERS, BODY) ## send email
session.close()
Now when i run this .py file...as pythonmail.py
i can see only statement
starting smtpmail......n details
then nothing on screen after few minutes or after pressing ctrl +c
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.conne ct(sa)
File "<string>", line 1, in connect
or may be conncetion time out
wats the solution for this
if i dont press cntrl + c then it shows
Starting SMTPmailsession on smtp.gmail.com as gogtesuy...@gma il.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SM TPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(ho st, port)
File "/usr/local/lib/python2.5/smtplib.py", line 310, in connect
raise socket.error, msg
socket.error: (110, 'Connection timed out')
plz help me its urgent.....i want to complete it as early as possible

I pasted your code into a file named temp.py,
and (perhaps superstitiously ) added a backslash to this line:
print 'Starting SMTPmailsession on %s as %s ' %

Here's what it does (long line wrapped manually):

peter@eleodes:~ $ python temp.py
Starting SMTPmailsession on smtp.gmail.com as ....@gmail.com
Traceback (most recent call last):
File "temp.py", line 27, in ?
session.login(S MTPuser, pw)
File "/usr/lib/python2.4/smtplib.py", line 591, in login
raise SMTPAuthenticat ionError(code, resp)
smtplib.SMTPAut henticationErro r: (535, \
'5.7.1 Username and Password not accepted. Learn more at\n' \
'5.7.1http://mail.google.com/support/bin/answer.py?answe r='\
'14257 a8sm34686663poa .12')
peter@eleodes:~ $

This indicates that it got much farther than when you ran it, since
your timeout message comes from the smtplib.SMTP call several lines
before the session.login call.

As a simple connectivity test, you might see whether you can connect
using telnet:

peter@eleodes:~ $ telnet smtp.gmail.com 587
Trying 72.14.253.109.. .
Connected to gmail-smtp.l.google.c om.
Escape character is '^]'.
220 mx.google.com ESMTP m27sm34789033po f.6
^]c

telnetc
Connection closed.
peter@eleodes:~ $

--
To email me, substitute nowhere->spamcop, invalid->net.
even i couldnt connect using telnet....
msg comes host is down
Sep 18 '08 #5
On Wed, 17 Sep 2008 23:53:36 -0700 (PDT), sui <go*********@gm ail.comwrote:
On Sep 17, 8:04 pm, Peter Pearson <ppear...@nowhe re.invalidwrote :
>On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <gogtesuy...@gm ail.comwrote:
[snip]
socket.error: (110, 'Connection timed out')
[snip]
>As a simple connectivity test, you might see whether you can connect
using telnet:
[snip]
even i couldnt connect using telnet....
msg comes host is down
Then your problem is a networking problem. I know even less about
networking than I know about Python. Can you ping the destination?
Perhaps tracepath or traceroute will help you find where your
messages are being refused. Perhaps you are trying to work through
an internet access provider (e.g., ISP) that doesn't allow direct
connections to remote mail servers.

If I might add a grouchy comment, you really should learn a
little about netiquette. When you don't bother to trim the
quoted context or even to punctuate your text, you broadcast
a conspicuous implication that you value your own time much
more than you value the time of the people whose help you're
soliciting, which is incongruous and insulting. A more
carefully presented request might have gotten a response
from someone more knowledgeable -- and less grouchy -- than
me.

--
To email me, substitute nowhere->spamcop, invalid->net.
Sep 18 '08 #6

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

Similar topics

1
1661
by: Kelly | last post by:
hi all, it's me again. i'm using ASP.NET Web Application, using a "File Field"component under HTML tab and i do a right click on the component and select "Run As Server Control". This was done because i wanted the user to browse a specific file in their own directory. Everything was working fine when i was working on my local PC.......The problem come when i placed the folder to the SERVER. Mapping to the...
2
3150
by: Eric Timely | last post by:
After a trust with exchange server established the xp_SendMail gives the following error: xp_sendmail: failed with mail error 0x80070005 Prior to the trust everything worked fine. I have tried the following: 1)Checking SQL and SQLAgents accounts all match up with default mail profile.
6
2054
by: Mike the Canadian | last post by:
I am having a very strange problem sending email with php. I have two domains. I can send an email to one domain using php but not the other. If I put both email addresses in the mail command only the one email will arrive. I can send emails the traditional way to the problem domain and they arrive fine. Is there anything that might explain this? _______ Free Windows Clipboard Utility http://www.clipboardmagic.com/
0
1416
by: Efim | last post by:
Hi, I have got some problem with sending of events in .NET. I am using remouting. The client has got 2 objects for receiving different types of events (responses and events) The server has got two objects for sending of these events. The client opens tcp port 0 to receive events: if (ChannelServices.GetChannel("tcp") == null) {
3
6829
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address (non-MyDomain.com address) I get the following error: The server rejected one or more recipient addresses. The server response was: 550 You must check your mail from this IP or SMTP Auth before sending to BSmith@Juno.com Here's the FULL...
4
6131
by: k.visube | last post by:
In my ASP application,i need to send a formatted text mail (i.e with newline characters). here in my application i used a function in javascript which construts the mail body sample snippet strbody=strbody +"dear customer,\n"; strbody=strbody +"we are glad to see ur response\n"; strbody=strbody +"we will make the needful thing as early as possible\n";
2
1592
by: =?Utf-8?B?YmFyYnlxMTA=?= | last post by:
After sending mail, it leaves the outbox as normal and clears and hits the sent folder, but then I get a popup box that states EMAIL PROBLEM One or more e-mail messages cannot be sent. Details
0
1567
Dormilich
by: Dormilich | last post by:
this is a follow-up thread to this one. http://bytes.com/topic/html-css/answers/863662-form-not-submitted-sometimes I figured out that the mail sending class triggers the described error. unfortunately, no error message is given by the system. <?php class Mail_Tabelle extends Mail_DB { protected $description = false; const TBL_HEAD = ' <thead>
2
2760
ThatThatGuy
by: ThatThatGuy | last post by:
Hello reader,, This might be a very simple question, but what to just say about it, i'm facing it Actually i'm developing a web App and i want email feature in that.... I'm sending mail from my development machine i.e localhost This is the setting in web.config <system.net> <mailSettings>
0
9282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9154
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
9048
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,...
1
6614
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4445
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
4708
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3142
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
2499
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2089
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.