08/07
2016
Discover IMAP/SMTP settings, authenticate via any email
A library to authenticate via an arbitrary email or/and to discover IMAP/SMTP settings by email address. Can be for example used in the projects where one doesn't need to keep a user entity in the database, but for which at the same time an authentication with service providers like Google is not enough., (*1)
php composer.phar require punarinta/email-auth:1.*
use \EmailAuth\Auth; $auth = new Auth; if ($auth->login('your@email', 'your-password')) { // You are authenticated. } elseif ($auth->status == Auth::STATUS_OAUTH_NEEDED) { // Please authenticate via OAuth. } else { // Thou shalt not pass! }
use \EmailAuth\Discover; $discover = new Discover; $config = $discover->imap('your@email'); echo "IMAP is on {$config['host']}:{$config['port']}, encryption is $config['encryption']}\n"; $config = $discover->smtp('your@email'); echo "SMTP is on {$config['host']}:{$config['port']}, encryption is $config['encryption']}\n";
No IMAP module is installed for PHP. Here's an example for PHP7 and Ubuntu how to fix it., (*2)
sudo apt-get install php7.0-imap sudo phpenmod imap
This project is licensed under the terms of MIT license., (*3)