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

Discussion in 'Python' started by online, Sep 6, 2009.

  1. online

    online Guest

    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 = '' # for SMTP AUTH, set SMTP username
    here
    smtppass = '123456' # for SMTP AUTH, set SMTP password here

    RECIPIENTS = ['']
    SENDER = ''

    msg = MIMEText('dsdsdsdsds\n')
    msg['Subject'] = 'The contents of iii'
    msg['From'] = ''
    msg['To'] = ''''

    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?
     
    online, Sep 6, 2009
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rodrigo
    Replies:
    1
    Views:
    852
    Marina
    Aug 28, 2003
  2. Replies:
    3
    Views:
    1,309
    Roedy Green
    Jan 24, 2006
  3. Alex Hunsley
    Replies:
    4
    Views:
    4,395
    Tim Williams (gmail)
    Jun 29, 2004
  4. Rk Ch
    Replies:
    0
    Views:
    198
    Rk Ch
    Nov 29, 2007
  5. Junkone
    Replies:
    2
    Views:
    242
    Thufir
    Dec 24, 2007
  6. Mikael H.
    Replies:
    1
    Views:
    426
    Robert Klemme
    Feb 21, 2011
  7. Ted Byers
    Replies:
    20
    Views:
    2,309
    Peter J. Holzer
    Jun 25, 2010
  8. ashish makani
    Replies:
    5
    Views:
    1,003
    Mark Lawrence
    Sep 20, 2012
Loading...