Sending emails with pyramid_mailer

101 views
Skip to first unread message

Mark Laskey

unread,
Mar 20, 2017, 1:57:21 AM3/20/17
to pylons-discuss
Hello all,
    I'm fairly new to Pyramid and have set up a basic application that has a contact form.  Upon submitting the contact form, I would like to send an email to my gmail account(just as a test for now) using pyramid_mailer.  I followed the documentation line by line and am having trouble sending out the email.  When I call the <pre>mailer.send(message)</pre> statement I get the following error:

<pre>ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it</pre>

In my development.ini file I have the following configuration:

<pre>
[app:myproj]
mail.host = smtp.gmail.com

mail.port = 587
mail.username = em...@gmail.com
mail.password = PASSWORD
mail.tls = True
</pre>

In my project's __init__.py file I have:
<pre>
from pyramid_mailer.mailer import Mailer

mailer = Mailer()

config = Configurator(settings=settings)
    config.registry['mailer'] = Mailer.from_settings(settings)
</pre>

I had to resort to using SMTPLib, which doesn't bother me, but I would like to use pyramid_mailer since it is a

Steve Piercy

unread,
Mar 20, 2017, 2:16:08 AM3/20/17
to pylons-...@googlegroups.com
The error message indicates that either there is a firewall
blocking the connection or the service is not listening on that port.

In order to send mail through Gmail servers, you need to use the
same information that you use to authenticate and send mail as
if it was your account in any mail client.
https://support.google.com/mail/answer/7126229?hl=en

You can try using SSL, instead of TLS, and port 465.

If you have set up your Google Account to require 2-step
verification, then you need to set up an app password. I had to
do this for my development machine. Read more:
https://support.google.com/accounts/answer/185833

--steve


On 3/19/17 at 5:52 PM, laskeym...@gmail.com (Mark Laskey) pronounced:
------------------------
Steve Piercy, Soquel, CA

Mark Laskey

unread,
Mar 20, 2017, 6:03:31 PM3/20/17
to pylons-discuss
Thanks Steve, I'll look into this once I get some time.  Also, excuse me for the tags, realized there was a code button once I submitted the OP,
Reply all
Reply to author
Forward
0 new messages