Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28904 > unrolled thread
| Started by | ashish makani <ashish.makani@gmail.com> |
|---|---|
| First post | 2012-09-11 14:51 -0700 |
| Last post | 2012-09-19 12:12 -0700 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.python
How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked ashish makani <ashish.makani@gmail.com> - 2012-09-11 14:51 -0700
Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-11 18:42 -0400
Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-11 23:47 +0100
Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked ashish <ashish.makani@gmail.com> - 2012-09-19 12:12 -0700
Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-20 08:56 +0100
Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked ashish <ashish.makani@gmail.com> - 2012-09-19 12:12 -0700
| From | ashish makani <ashish.makani@gmail.com> |
|---|---|
| Date | 2012-09-11 14:51 -0700 |
| Subject | How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked |
| Message-ID | <0f6686fd-7363-43d6-a5fa-0bd4f12586b5@googlegroups.com> |
Hi c.l.p peeps
I am stuck with an issue, so am coming to the Pythonista deltaforce 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')
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@gmail.com', 'y@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) :(
So , when i try to run the 2 py statements (in bold below) on a python prompt from the production server, which has port 587 blocked, i get the following error
{
>>> import smtplib
>>> server = smtplib.SMTP('smtp.gmail.com:587')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.6/smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
File "/usr/lib/python2.6/socket.py", line 514, in create_connection
raise error, msg
socket.error: [Errno 101] Network is unreachable
}
1. How can i overcome this ?
A friend suggested , that i could use something called smtp relay, which would solve my problem, but would be time-consuming & a pain to set up.
I did some cursory googling & searching on stackoverflow but could not find any good, well explained results.
I dont know anything about SMTP.
Anybody has any recommendations on a good explanation on smtp relay & how to set it up for sending email from a gmail a/c using a python script ?
2. Also, is there a more elegant/cleaner/graceful solution to my problem than using an smtp relay ?
Any & all explanations/links/code snippets/thoughts/ideas/suggestions/feedback/comments/wisdom of the c.l.p community would be greatly appreciated.
Thanks a ton
cheers
ashish
email :
ashish.makani
domain:gmail.com
p.s. some more context so people dont presume we are spammers :)
These emails are automated diagnostic emails sent to a group of a few of us admins, so we get notified when a python heartbeat script, detects a failure in things like n/w connectivity, router status, etc.
All of us dont use university email, we use gmail .
“The only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it.” - Steve Jobs (1955 - 2011)
[toc] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-09-11 18:42 -0400 |
| Message-ID | <mailman.522.1347403322.27098.python-list@python.org> |
| In reply to | #28904 |
On Tue, 11 Sep 2012 14:51:23 -0700 (PDT), ashish makani
<ashish.makani@gmail.com> declaimed the following in
gmane.comp.python.general:
>
> 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) :(
>
> So , when i try to run the 2 py statements (in bold below) on a python prompt from the production server, which has port 587 blocked, i get the following error
>
<snip>
>
> 1. How can i overcome this ?
> A friend suggested , that i could use something called smtp relay, which would solve my problem, but would be time-consuming & a pain to set up.
Which is correct... And is nothing YOU will set up (if you had the
privileges to create an SMTP daemon, you'd have the privileges to use a
blocked port).
Just replace the SMTP server, username, and password with the
relevant information for your university system. It shouldn't matter
that the email identifies to recipients with a Google email ID -- all
you change is the /server/ that sends the email to the world.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-09-11 23:47 +0100 |
| Message-ID | <mailman.523.1347403684.27098.python-list@python.org> |
| In reply to | #28904 |
On 11/09/2012 22:51, ashish makani wrote: > Hi c.l.p peeps > > I am stuck with an issue, so am coming to the Pythonista deltaforce who rescue me everytime :) > [big snip] I say old chap, it's simply not cricket to ask a question like this some 32 minutes after asking the same question on the tutor mailing list. -- Cheers. Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | ashish <ashish.makani@gmail.com> |
|---|---|
| Date | 2012-09-19 12:12 -0700 |
| Message-ID | <30853fb3-ef5a-4304-9123-15c84a2f9c89@googlegroups.com> |
| In reply to | #28908 |
Folks, I asked the same query on the python tutor mailing list. The responses i received are here : http://thread.gmane.org/gmane.comp.python.tutor/77601 Mark, There is nothing wrong in asking a query on multiple forums. Poeple on the tutor list, may not be part of comp.lang.python & subscribers to comp.lang.python On Wednesday, September 12, 2012 4:18:05 AM UTC+5:30, Mark Lawrence wrote: > On 11/09/2012 22:51, ashish makani wrote: > > > Hi c.l.p peeps > > > > > > I am stuck with an issue, so am coming to the Pythonista deltaforce who rescue me everytime :) > > > > > > > [big snip] > > > > I say old chap, it's simply not cricket to ask a question like this some > > 32 minutes after asking the same question on the tutor mailing list. > > > > -- > > Cheers. > > > > Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-09-20 08:56 +0100 |
| Message-ID | <mailman.954.1348127735.27098.python-list@python.org> |
| In reply to | #29519 |
On 19/09/2012 20:12, ashish wrote: > Folks, > > I asked the same query on the python tutor mailing list. > The responses i received are here : > http://thread.gmane.org/gmane.comp.python.tutor/77601 > > > Mark, > > There is nothing wrong in asking a query on multiple forums. > > Poeple on the tutor list, may not be part of comp.lang.python & subscribers to comp.lang.python > And you've done exactly the same thing with another question. So there are two sets of answers on two mls/ngs that are completely unconnected except that I amongst others know that they exist. If you had to ask on both, why not post to both in one hit? -- Cheers. Mark Lawrence.
[toc] | [prev] | [next] | [standalone]
| From | ashish <ashish.makani@gmail.com> |
|---|---|
| Date | 2012-09-19 12:12 -0700 |
| Message-ID | <mailman.937.1348082634.27098.python-list@python.org> |
| In reply to | #28908 |
Folks, I asked the same query on the python tutor mailing list. The responses i received are here : http://thread.gmane.org/gmane.comp.python.tutor/77601 Mark, There is nothing wrong in asking a query on multiple forums. Poeple on the tutor list, may not be part of comp.lang.python & subscribers to comp.lang.python On Wednesday, September 12, 2012 4:18:05 AM UTC+5:30, Mark Lawrence wrote: > On 11/09/2012 22:51, ashish makani wrote: > > > Hi c.l.p peeps > > > > > > I am stuck with an issue, so am coming to the Pythonista deltaforce who rescue me everytime :) > > > > > > > [big snip] > > > > I say old chap, it's simply not cricket to ask a question like this some > > 32 minutes after asking the same question on the tutor mailing list. > > > > -- > > Cheers. > > > > Mark Lawrence.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web