0

Though I copy pasted password and email but get SMTP Authentication Error 535 : "Username and Password not accepted"

app = Flask(__name__)
app.config['DEBUG']=True
app.config['TESTING'] = False
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT']=465
app.config['MAIL_USE_SSL']=True
app.config['MAIL_USE_TLS']=False
app.config['MAIL_USERNAME'] = 'name@gmail.com'
app.config['MAIL_PASSWORD']= '*******'
app.config['MAIL_DEFAULT_SENDER'] = 'name@gmail.com'
app.config['MAIL_ASCII_ATTACHMENTS'] = False

mail = Mail(app)

@app.route('/-/-/-/-/-/robot')
def robot():
    msg = Message("Hello", recipients=["*********@gmail.com"])
    msg.body = "Hey!"
    mail.send(msg)
    return 'sent'

What's wrong with that ?

Smack Alpha
  • 1,828
  • 1
  • 17
  • 37
  • 1
    currently GMail uses more restricted method to access account. You may have to set in GMail's options "give access for less trusted applications" or you have to activate 2-way authorization and assign individual password for your application. It may not work with password which you use to login to GMail in web browser. – furas Oct 20 '19 at 16:35
  • [Allow less secure apps to access your Gmail account](https://devanswers.co/allow-less-secure-apps-access-gmail-account/) and [How to Create an App Password for Gmail](https://devanswers.co/create-application-specific-password-gmail/) – furas Oct 20 '19 at 16:38
  • thank you @furas . finally it's working. – Shafiul Alam Shiam Oct 20 '19 at 18:43

0 Answers0