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/>')
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 <mailto:x...@gmail.com>', 'y...@gmail.com
<mailto: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) :(

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@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to