aednzxy/email-auth

发现 IMAP/SMTP 设置,通过任何电子邮件进行认证

v1.4 2020-04-28 23:14 UTC

This package is auto-updated.

Last update: 2024-09-29 05:36:12 UTC


README

一个用于通过任意电子邮件或/和通过电子邮件地址发现 IMAP/SMTP 设置的库。例如,可以用于那些不需要在数据库中保留用户实体的项目,但同时又不足以通过像 Google 这样的服务提供商进行认证的项目。

安装

示例用法

认证

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";

故障排除

致命错误:调用未定义的函数 imap_open()

PHP 没有安装 IMAP 模块。以下是在 PHP7 和 Ubuntu 上修复此问题的示例。

sudo apt-get install php7.0-imap
sudo phpenmod imap

许可

本项目根据 MIT 许可证条款授权。