473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 3092
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.