Sending email connection error

337 views
Skip to first unread message

dbv

unread,
Nov 23, 2012, 7:11:38 AM11/23/12
to cork-d...@googlegroups.com
Running the simple_webapp.py example starting with the signup (register) process using my email providers smtp url.  Getting a connection failed error and not sure where the problem is.  Here is the error message:

localhost - - [2012-11-23 02:49:30,640] Error sending email: [Errno 10060] A con
nection attempt failed because the connected party did not properly respond afte
r a period of time, or established connection failed because connected host has
failed to respond
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\bottle_cork-0.3-py2.7.egg\cork\cork.py", l
ine 662, in _send
    session = SMTP(self._conf['fqdn'])
  File "C:\Python27\lib\smtplib.py", line 249, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python27\lib\smtplib.py", line 309, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Python27\lib\smtplib.py", line 284, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "C:\Python27\lib\socket.py", line 571, in create_connection
    raise err
error: [Errno 10060] A connection attempt failed because the connected party did
 not properly respond after a period of time, or established connection failed b
ecause connected host has failed to respond

Thanks!

Federico Ceratto

unread,
Nov 26, 2012, 5:26:04 AM11/26/12
to cork-d...@googlegroups.com
On Fri, Nov 23, 2012 at 12:11 PM, dbv <dinesh...@hotmail.com> wrote:
[...]
> error: [Errno 10060] A connection attempt failed because the connected party
> did not properly respond after a period of time, or established connection
> failed because connected host has failed to respond

Hi. This is an error from the socket module.
If the problem is not persistent, looks like your mailserver was not
responsive at the time.
Otherwise, make sure that the configuration string (protocol, server
name, port number) is correct.

Bye,
--
Federico

dbv

unread,
Nov 26, 2012, 9:21:39 AM11/26/12
to cork-d...@googlegroups.com
It is persistent.

Should the argument list for Cork() __init()__ include: proto=None and port=None ?

Still doesn't send registration email ... uhmm!

Federico Ceratto

unread,
Nov 26, 2012, 9:59:06 AM11/26/12
to cork-d...@googlegroups.com
On Mon, Nov 26, 2012 at 2:21 PM, dbv <dinesh...@hotmail.com> wrote:
> It is persistent.
>
> Should the argument list for Cork() __init()__ include: proto=None and
> port=None ?

You can use smtp_url as:
<protocol>://[<username>[:<password>]@]<fqdn>[:<port_number>]/
where protocol can be: smtp, starttls, ssl
Username, password, port_number are optional.

Here is an example:
https://github.com/FedericoCeratto/bottle-cork/blob/master/examples/simple_webapp.py#L19

I'll update the documentation accordingly.

Bye,
--
Federico

dbv

unread,
Nov 26, 2012, 12:13:07 PM11/26/12
to cork-d...@googlegroups.com
Still not working but here are some clues:

a) The email account I'm using requires username/password authentication.  But, the username is an email address which the Mailer regex doesn't parse correctly.

b) SMTP_SSL from smtplib might be better but won't know for sure until a) is fixed.

Hth

Federico Ceratto

unread,
Nov 27, 2012, 11:41:55 AM11/27/12
to cork-d...@googlegroups.com
On Mon, Nov 26, 2012 at 5:13 PM, dbv <dinesh...@hotmail.com> wrote:
> Still not working but here are some clues:
>
> a) The email account I'm using requires username/password authentication.
> But, the username is an email address which the Mailer regex doesn't parse
> correctly.

Thanks for the bugreport. SMTP usernames may contain "@" and the
Mailer regexp should be able to handle that.
The "url" syntax is used similarly by other applications, e.g. mutt:
http://durak.org/sean/pubs/software/mutt/optionalfeatures.html


> b) SMTP_SSL from smtplib might be better but won't know for sure until a) is
> fixed.

SSL mode is not supported at the moment (but implementing would
probably require a short time):
https://github.com/FedericoCeratto/bottle-cork/blob/master/cork/cork.py#L821


--
Federico

dbv

unread,
Nov 27, 2012, 1:31:50 PM11/27/12
to cork-d...@googlegroups.com
a) If the username contains "@" then it does break the Mailer regex.  Debugged by printing-out d = match.groupdict() which shows that it breaks.

b) I tried with SMTP_SSL and the program moved further then with SMTP but failed at a).  If a) is fixed then maybe using SMPT_SSL will work and solve the original problem.

Message has been deleted

Federico Ceratto

unread,
Nov 28, 2012, 4:31:19 PM11/28/12
to cork-d...@googlegroups.com
On Tue, Nov 27, 2012 at 4:41 PM, Federico Ceratto
<federico...@gmail.com> wrote:
> Thanks for the bugreport. SMTP usernames may contain "@" and the
> Mailer regexp should be able to handle that.
> The "url" syntax is used similarly by other applications, e.g. mutt:
> http://durak.org/sean/pubs/software/mutt/optionalfeatures.html

Ok, the regex (in the development branch on Github) is now able to
handle the at sign in the username.

> SSL mode is not supported at the moment (but implementing would
> probably require a short time):

Also, SSL is implemented.

Testing and feedback is welcome!

--
Federico

dbv

unread,
Nov 28, 2012, 6:19:50 PM11/28/12
to cork-d...@googlegroups.com
a. Mailer regex
Works perfectly.

b. Email sent?
No.  
In cork.py, because the username:password are sent in the smtp string, I added:
 
user = self._conf['user']

and the check:

if user != "": instead of if proto == 'ssl':

And, this sent the email.

dbv

unread,
Dec 6, 2012, 12:23:35 PM12/6/12
to cork-d...@googlegroups.com
Testing simple_webapp.py on EC2 instance with:
bottle.run(app=app, host="myec2site", port=80, quiet=False, reloader=True)
where myec2site points to the IP address in the hosts file, and got the error:
error: [Errno 99] Cannot assign requested address
Posted on Bottle group too.  Any ideas?

dbv

unread,
Dec 6, 2012, 4:06:26 PM12/6/12
to cork-d...@googlegroups.com
I guess Bottle does not support alphanumeric host names in hosts files?

Also tried:

1. bottle.run (host = 'xxx.xxx.xxx. xxx ', port = 80) where xxx.xxx.xxx.xxx = EC2 public IP address.
The error is: socket.error: address [Errno 99] Can not assign requested address

2. bottle.run (host = '0 .0.0.0 ', port = 8080)
Says, listening on http://0.0.0.0:8080/ but entering EC2 public IP address xxx.xxx.xxx.xxx browser does not find page.

Any ideas what the problem could be?

dbv

unread,
Dec 7, 2012, 8:44:42 AM12/7/12
to cork-d...@googlegroups.com
My bad: port 0.0.0.0:8080 wasn't opened at the EC2 and so it now works.  However, we want to use the EC2 public IP address in a IP:PORT combination and I guess that is supported when we replace the bottle standard server with Nginx, for example?
Reply all
Reply to author
Forward
0 new messages