FAQ - PHP IMAP with Google, Microsoft and Yahoo

PHP IMAP with Google, Microsoft and Yahoo

26.01.2023 793


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:

  1. Login to your Gmail Account
  2. Go to https://myaccount.google.com
  3. Go to Security
  4. Activate the 2 step verification
  5. Add an App Password for Email
  6. Use this app password for the php imap connection

two factor

create app password

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