Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Gmail Error using smtplib

Reply
Thread Tools

Gmail Error using smtplib

 
 
DJ Fadereu
Guest
Posts: n/a
 
      07-20-2007
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 Removed)'


msg['Subject'] = 'Hello'
msg ['From'] = '(E-Mail Removed)'
msg['To'] = '(E-Mail Removed)'

s = smtplib.SMTP('alt1.gmail-smtp-in.l.google.com')
s.set_debuglevel(1)
s.login('(E-Mail 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 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.

 
Reply With Quote
 
 
 
 
supercooper
Guest
Posts: n/a
 
      07-20-2007
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 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()



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: smtplib send email by using gmail smtp server Gabriel Genellina Python 0 05-03-2009 06:08 PM
[SMTPLIB] how to send a "Multiline" mail with smtplib? Evan Python 3 06-23-2008 08:50 AM
Re: Gmail Error using smtplib Tim Williams Python 0 07-20-2007 12:44 PM
Re: smtplib starttls gmail example Jean-Paul Calderone Python 0 01-23-2007 05:37 PM
smtplib starttls gmail example py Python 0 01-23-2007 05:25 PM



Advertisments