Learn how to send emails with PHP in an authenticated way, using a gmail account as an example.
HOST = smtp.gmail.com
USER = Add your gmail address, example: exemplo@gmail.com
PORT = 465
Enable SMTP Authentication: YES
PASSWORD
For customers using the Gmail provider, the following process must be performed to create a password for sending and receiving emails.
1 - Go to gmail settings and enable IMAP access.
2 - Open your Google Account.
In the navigation pane select Security.
Under "Signing in to Google", select 2-Step Verification after Get Started.
Follow the steps displayed on the screen.
With this, the two-step verification will be active, now just create the app password, performing the following process.
3 - Open your Google Account.
Select Security.
Under "Signing in to Google", select App passwords. You may need to sign in. If you don't have this option, it could be because:
2-step verification is not set up on your account;
two-step verification is configured for security keys only;
you use an account at work, school, or another organization;
you have enabled Advanced Protection.
At the bottom choose Select app and choose the app you are using choose Select device and choose the device you are using Generate.
Follow the instructions to enter the app password. It's the 16-character code on your device's yellow bar.
Tap Done.
After performing these steps, the app password will be created, just enter it in the password field of the products in the email settings.