Emailing smtp with Python error

Posted by jakecar on Stack Overflow See other posts from Stack Overflow or by jakecar
Published on 2010-05-27T03:29:30Z Indexed on 2010/05/27 3:31 UTC
Read the original article Hit count: 339

Filed under:
|
|

I can't figure out why this isn't working. I'm trying to send an email from my school email address with this code I got online. The same code works for sending from my GMail address. Does anyone know what this error means? The error occurs after waiting for about one and a half minutes.

import smtplib

FROMADDR = "FROM_EMAIL"
LOGIN    = "USERNAME"
PASSWORD = "PASSWORD"
TOADDRS  = ["TO_EMAIL"]
SUBJECT  = "Test"

msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
    % (FROMADDR, ", ".join(TOADDRS), SUBJECT) )
msg += "some text\r\n"

server = smtplib.SMTP('OUTGOING_SMTP', 587)
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.login(LOGIN, PASSWORD)
server.sendmail(FROMADDR, TOADDRS, msg)
server.quit()

And here's the error I get:


    Traceback (most recent call last): 
      File "emailer.py", line 13, in 
    server = smtplib.SMTP('OUTGOING_SMTP', 587)
    File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py", line 239, in init
    (code, msg) = self.connect(host, port)
   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py", line 514, in create_connection
    raise error, msg
socket.error: [Errno 60] Operation timed out

© Stack Overflow or respective owner

Related posts about python

Related posts about email