Gmail required applications that will use their service to be authorized first beforehand. Failure in doing this will cause SMTP sending mail process fail with the response "534-5.7.9 Application-specific password required...".
To solve this issue, you need to give this application an App password that is generated from Gmail account.
Here are the steps:
-
Go to https://myaccount.google.com/intro and login to your Gmail account. Then click on Security tab from the top navbar. You will see this section:
-
In the section Signing in to Google select 2-step verification and follow the prompts to turn it ON.
-
Once step 2 completed, go back to Security page and from the same section (Signing in to Google) select App password.
-
Under Select the app and device you want to generate the app password for.:
- for Select app choose Mail
- for Select device choose Other (Custom name) then type MentorshipSystem (or choose any name you like)
-
Once you completed step 3 above, a window will open and show the autogenerated password that you can use for the application. Copy paste this code to your .env as the value for APP_MAIL_PASSWORD. Click done on the open window (back to Gmail account window), then you will see it on the App passwords list.
-
Make sure you have your MAIL_SERVER config in the
.env
set to smtp.gmail.com and both MAIL_DEFAULT_SENDER and APP_MAIL_USERNAME set to the Gmail account you just authorized the app with. -
Save and run the python script again from the command line:
python run.py
. Then try to register a new user on the Swagger UI. This should give HTTP response 200 (successful).