python smtp gmail authentication error (sending email through gmailsmtp server)

O

online

Hi all,

I have the following code

import smtplib
from email.mime.text import MIMEText



smtpserver = 'smtp.gmail.com'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = '(e-mail address removed)' # for SMTP AUTH, set SMTP username
here
smtppass = '123456' # for SMTP AUTH, set SMTP password here

RECIPIENTS = ['(e-mail address removed)']
SENDER = '(e-mail address removed)'

msg = MIMEText('dsdsdsdsds\n')
msg['Subject'] = 'The contents of iii'
msg['From'] = '(e-mail address removed)'
msg['To'] = ''(e-mail address removed)''

mailServer = smtplib.SMTP('smtp.gmail.com',587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(smtpuser, smtppass)
mailServer.sendmail(smtpuser,RECIPIENTS,msg.as_string())
mailServer.close()


this code works fine on my desktop. but it failed with this error

smtplib.SMTPAuthenticationError: (535, '5.7.1 Username and
Password not accepted. Learn more at\n5.7.1
http://mail.google.com/support/bin/answer.py?answer=14257
21sm4713429agd.11')

on my linux server.

Not sure what went wrong, should i open some port/ install some
services on my linux server?
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top