punarinta / email-auth
发现IMAP/SMTP设置,通过任何邮箱进行认证
v1.0
2016-07-08 08:32 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-14 19:36:58 UTC
README
一个库,可以通过任意邮箱或/和通过邮箱地址发现IMAP/SMTP设置进行认证。例如,可以在那些不需要在数据库中保留用户实体,但同时又不足以使用像Google这样的服务提供商进行认证的项目中使用。
安装
- 安装Composer: https://getcomposer.org.cn/download
- 运行
php composer.phar require punarinta/email-auth:1.*
- 确保从vendor目录包含"autoload.php"文件
示例用法
认证
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许可证的条款授权。