Connecting to Gmail with imap_open

David Carr

IMAP Tutorials PHP & MySQL

Using PHP connecting to an POP/IMAP server is a relatively easy process, it can be useful for using webmail or to allow a script to download all emails and store in a database for instance.

The function required to make the connection is imap_open, it expects three parameters first the connection string made up of the remote host and mailbox folder, followed by the username and password.

a typical example:

imap_open("{imap.gmail.com:993/ssl/novalidate-cert}INBOX","user@gmail.com","passwordofuser") or die(imap_errors()); 

The above should work just fine, I've found a large number of blogs/articles using that path. 
I've not had any success with that, Google may have updated this recently, tested the above locally and on a remote server.

In order to make the connection remove the novalidate-cert.

imap_open("{imap.gmail.com:993/ssl}INBOX","user@gmail.com","passwordofuser") or die(imap_errors()); 

 

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.