472,374 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

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,SMTPuser)
session = smtplib.SMTP(SMTPserver,port)
session.set_debuglevel(0) # set debug level to 1 to see details
session.ehlo(SMTPuser) # say hello
session.starttls() # TLS needed
session.ehlo(SMTPuser) # 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.sendmail(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(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.connect(sa)
File "<string>", line 1, in connect
or may be conncetion time out

wats the solution for this
Sep 17 '08 #1
5 3002
sui
On Sep 17, 5:04 pm, sui <gogtesuy...@gmail.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,SMTPuser)
session = smtplib.SMTP(SMTPserver,port)
session.set_debuglevel(0) # set debug level to 1 to see details
session.ehlo(SMTPuser) # say hello
session.starttls() # TLS needed
session.ehlo(SMTPuser) # 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.sendmail(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(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.connect(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*********@gmail.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, 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*********@gmail.comwrote:
On Sep 17, 5:04 pm, sui <gogtesuy...@gmail.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,SMTPuser)
session = smtplib.SMTP(SMTPserver,port)
session.set_debuglevel(0) # set debug level to 1 to see details
session.ehlo(SMTPuser) # say hello
session.starttls() # TLS needed
session.ehlo(SMTPuser) # 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.sendmail(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(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.connect(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*********@gmail.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, 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(SMTPuser, pw)
File "/usr/lib/python2.4/smtplib.py", line 591, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, \
'5.7.1 Username and Password not accepted. Learn more at\n' \
'5.7.1 http://mail.google.com/support/bin/answer.py?answer=' \
'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.com.
Escape character is '^]'.
220 mx.google.com ESMTP m27sm34789033pof.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...@nowhere.invalidwrote:
On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <gogtesuy...@gmail.comwrote:
On Sep 17, 5:04 pm, sui <gogtesuy...@gmail.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,SMTPuser)
session = smtplib.SMTP(SMTPserver,port)
session.set_debuglevel(0) # set debug level to 1 to see details
session.ehlo(SMTPuser) # say hello
session.starttls() # TLS needed
session.ehlo(SMTPuser) # 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.sendmail(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(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.connect(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...@gmail.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, 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(SMTPuser, pw)
File "/usr/lib/python2.4/smtplib.py", line 591, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, \
'5.7.1 Username and Password not accepted. Learn more at\n' \
'5.7.1http://mail.google.com/support/bin/answer.py?answer='\
'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.com.
Escape character is '^]'.
220 mx.google.com ESMTP m27sm34789033pof.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...@nowhere.invalidwrote:
On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <gogtesuy...@gmail.comwrote:
On Sep 17, 5:04 pm, sui <gogtesuy...@gmail.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,SMTPuser)
session = smtplib.SMTP(SMTPserver,port)
session.set_debuglevel(0) # set debug level to 1 to see details
session.ehlo(SMTPuser) # say hello
session.starttls() # TLS needed
session.ehlo(SMTPuser) # 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.sendmail(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(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect
self.sock.connect(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...@gmail.com
Traceback (most recent call last):
File "mail4.py", line 21, in <module>
session = smtplib.SMTP(SMTPserver,port)
File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, 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(SMTPuser, pw)
File "/usr/lib/python2.4/smtplib.py", line 591, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, \
'5.7.1 Username and Password not accepted. Learn more at\n' \
'5.7.1http://mail.google.com/support/bin/answer.py?answer='\
'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.com.
Escape character is '^]'.
220 mx.google.com ESMTP m27sm34789033pof.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*********@gmail.comwrote:
On Sep 17, 8:04 pm, Peter Pearson <ppear...@nowhere.invalidwrote:
>On Wed, 17 Sep 2008 05:28:05 -0700 (PDT), sui <gogtesuy...@gmail.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
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...
2
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...
6
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...
0
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...
3
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...
4
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 ...
2
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. ...
0
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....
2
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.