Issue sending email with python?

Viewed 7003

I'm trying to make an email script in python. Here's what I have (from pythonlibrary.org):

#! /usr/bin/env python

import smtplib
import string

SUBJECT = "An email!"
TO = "me@icloud.com"
FROM = "me@gmail.com"
text = "This text is the contents of an email!"
BODY = string.join((
        "From: %s" % FROM,
        "To: %s" % TO,
        "Subject: %s" % SUBJECT ,
        "",
        text
        ), "\r\n")
server = smtplib.SMTP('smtp.gmail.com')
server.login('me@gmail.com', 'mypassword') # Not very secure, I know, but this email is dedicated to this script
server.sendmail(FROM, [TO], BODY)
server.quit()

I get smtplib.SMTPException: SMTP AUTH extension not supported by server. Is this is so, then why does smtp.gmail.com respond at all? Is this a problem with Gmail, or my script, or something else?

Error message:

Traceback (most recent call last):
  File "/Users/student/Desktop/mail.py", line 18, in <module>
    server.login('*******@gmail.com', '**************')
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py", line 552, in login
smtplib.SMTPException: SMTP AUTH extension not supported by server.
3 Answers
Related