Gmail Error using smtplib

D

DJ Fadereu

Hello, can anyone help me with this? What am I doing wrong here?

(I've changed private info to yyyy/xxxxxx)
I'm getting an authentication error while using a standard script
Gmail:
--------------------------SCRIPT-----------------------------
import smtplib
from email.MIMEText import MIMEText

msg = MIMEText('Hello, this is fadereu...')
From = '(e-mail address removed)'

msg['Subject'] = 'Hello'
msg ['From'] = '(e-mail address removed)'
msg['To'] = '(e-mail address removed)'

s = smtplib.SMTP('alt1.gmail-smtp-in.l.google.com')
s.set_debuglevel(1)
s.login('(e-mail address removed)','xxxxxxxxx')
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.close()
----------------------------ERROR------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\Acer User\Desktop\Code\S60 scripts
\Fadereu's Codez\gmail.py", line 13, in <module>
s.login('(e-mail address removed)','xxxxxxxxx'')
File "C:\Python25\lib\smtplib.py", line 554, in login
raise SMTPException("SMTP AUTH extension not supported by
server.")
SMTPException: SMTP AUTH extension not supported by server.
 
S

supercooper

This works for me...

def SendEmail(msgType,sender,recipient,subject,message):
"""
Sends either a log file or a string message in email to
recipient.
Uses Google smtp server to send the mail.

CHANGELOG:
2006-12-7: Set sender, recipient, subject as input variables

---------------------------------------------------------------------------------------------
Inputs:
msgType: If 'log', message is path to log file that is to be
written into email body
sender: Senders email addy
recipient: Who we want to send to
subject: Email subject line
message: Message body of email

---------------------------------------------------------------------------------------------
"""
# determine msg type
if msgType == 'log':
# Send log file in email
fp = open(message, 'rb')
# Create a text/plain message
# Read contents of log file into memory
msg = MIMEText(fp.read())
fp.close()
else:
# If not a log file, just create a text/plain message
msg = MIMEText(message)

# User/pwd
me = '(e-mail address removed)'
pwd = 'pass'

# Build the email
fromAddr = sender
toAddr = recipient
msg['Subject'] = subject
msg['From'] = fromAddr
msg['To'] = toAddr

# Set up and connect to smtp server
server = smtplib.SMTP('smtp.gmail.com', 587)
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.ehlo()
server.login(me, pwd)
# Send the email
server.sendmail(fromAddr, toAddr, msg.as_string())
server.close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top