[Tutor] How to send email from a gmail a/c using smtp when port 587(smtp) is blocked

Marc Tompkins marc.tompkins at gmail.com
Tue Sep 11 23:58:09 CEST 2012


On Tue, Sep 11, 2012 at 2:44 PM, ashish makani <ashish.makani at gmail.com>wrote:

> Folks,
>
> some more context so people presume we are spammers :)
>
> These emails are automated diagnostic emails sent to a group of a few
> admins, so we get notified when a python heartbeat script, detects a
> failure in things like n/w connectivity, router status, etc.
> We dont use university email, we use gmail.
>
> Emile,
> Please don't presume people's intentions (that we are sending spam) &
> judge people without knowing anything about them.
> We are a tiny startup trying to connect rural communities using voice &
> ivr systems - http://gramvaani.org/
>
>
I think you might have been presuming Emile's intention too...

Blocking port 587 is a standard, prudent, and correct action for the
university (ANY network that allows guest access, actually) to take to help
prevent spam.  The problem is that you (and I do, truly, presume that your
intentions are honorable) would not be the only person/system that could
use port 587 if it were unblocked.  Sure, we trust YOU - but what about
everybody else?

So there are several ways to go about this:
  -  the standard way, which would be to use the university's SMTP server -
which can require a username/password before sending; not perfect but
better than nothing
  -  you can work with the university's network admin to grant you or your
app an exception to the firewall rule - IF their firewall, and their
policies, allow such an exception
  -  you could establish a VPN tunnel to some server outside of the
university's network and send from port 587 on THAT machine.  Complicated,
weird, and not horribly secure.  But doable.




> Best,
> ashish
>
>
> On Wed, Sep 12, 2012 at 2:56 AM, Emile van Sebille <emile at fenx.com> wrote:
>
>> On 9/11/2012 2:19 PM ashish makani said...
>>
>>> Hi Python Tutor folks
>>>
>>> I am stuck with an issue, so am coming to the Pythonistas who rescue me
>>> everytime :)
>>>
>>> I am trying to send out email programmatically, from a gmail a/c, using
>>> smtplib, using the following chunk of code (b/w [ & ] below)
>>>
>>> [
>>>
>>> import smtplib
>>> from email.mime.text import MIMEText
>>>
>>> #uname, pwd are username & password of gmail a/c i am trying to send from
>>>
>>> server = smtplib.SMTP('smtp.gmail.com:**587 <http://smtp.gmail.com:587><
>>> http://smtp.gmail.com:587/>')
>>>
>>> server.starttls() # get response(220, '2.0.0 Ready to start TLS')
>>> server.login(uname,pwd)  # get response(235, '2.7.0 Accepted')
>>>
>>> toaddrs  = ['x at gmail.com <mailto:x at gmail.com>', 'y at gmail.com
>>> <mailto:y at gmail.com>' ] # list of To email addresses
>>>
>>> msg = MIMEText('email body')
>>> msg['Subject'] = 'email subject'
>>> server.sendmail(fromaddr, toaddrs, msg.as_string())
>>>
>>>
>>> ]
>>>
>>> The code above works perfectly fine on my local machine, but fails on
>>> the production server at the university where i work( all ports other
>>> than port 80 are blocked) :(
>>>
>>
>> Good -- the university is taking steps to block spam.
>>
>> You should send mail using the university mail system and not
>> smtp.gmail.com.
>>
>> Emile
>>
>>
>> ______________________________**_________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120911/6d835ffe/attachment.html>


More information about the Tutor mailing list