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.
- Install Composer: https://getcomposer.org/download
- Run
php composer.phar require punarinta/email-auth:1.*
- Assure "autoload.php" file from vendor directory is included
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.
sudo apt-get install php7.0-imap
sudo phpenmod imap
This project is licensed under the terms of MIT license.