PHP IMAP with Google, Microsoft and Yahoo
26.01.2023 1512
How to setup a PHP IMAP connection with Google, Microsoft and Yahoo. A question we often get asked, and most of you think it is not possible because all of them have made OAuth mandatory for their services.
Good News, it is still possible without issues but it needs a little more steps to setup.
Google
With Google (Gmail), you will need to do following steps:
- Login to your Gmail Account
- Go to https://myaccount.google.com
- Go to Security
- Activate the 2 step verification
- Add an App Password for Email
- Use this app password for the php imap connection
Settings for the PHP IMAP Connection
The settings for Google are as following:
- Mailbox: imap.gmail.com:993
- Username: your gmail email address
- Password: The app password you have received
- Encryption: ssl
- Folder to scan: INBOX (capital letters)
- Email: your gmail email address
The settings for Microsoft are as following:
- Mailbox: outlook.office365.com:993
- Username: your microsoft email address
- Password: The app password you have received
- Encryption: ssl
- Folder to scan: INBOX (capital letters)
- Email: your microsoft email address
The settings for Yahoo are as following:
- Mailbox: imap.mail.yahoo.com:993
- Username: your microsoft email address
- Password: The app password you have received
- Encryption: ssl
- Folder to scan: INBOX (capital letters)
- Email: your microsoft email address