actweb/mail-auth
Composer 安装命令:
composer require actweb/mail-auth
包简介
Mail server authentication class, allows authenticating users against POP/IMAP/SMTP with or without SSL
README 文档
README
Overview
PHP Class to authenticate a user against a mail server.
Specification
Allow setting of auth type : POP3, POP3S, IMAP, IMAPS, SMTP, SMTPS.
Take a username and a password and then attempt a login to the specified mail server.
If login is successful, then return true, else return false.
SMTP authentication function adapted from : http://support.webecs.com/kb/a390/php-mail-script-with-smtp-authentication.aspx
Usage
| Configurable settings | Default Value | Description |
|---|---|---|
| mailServerUrl | NONE | Mailserver URL |
| serverPort | NONE | Mailserver Port number, normally automatically set after by setting the serverType, but can be overridden if required |
| serverType | NONE | Service to use for authentication POP3/POP3S/IMAP/IMAPS/SMTP/SMTPS |
| serverTypes | Array of Types | Built in list of valid services for authentication |
| errors | Array of Errors | List of all error codes, there description and some help text on what the issue may be |
| username | NONE | Set to the username to be used for authentication |
| password | NONE | Set to the password to be used for authentication |
| passwordType | plain | Currently on 'plain' is used, possible future enhancement to allow form based password encryption |
| passwordTypes | List of supported passwordTypes, currently only 'plain' is supported | |
| logger | Null Logger | \Monolog\Logger if passed to constructor, this is used for all logging |
| sslCheck | true | If true, then perform SSL verification on the connection. NOTE If using POP or IMAP, this should be set to 'false' as some bug causes PHP imap_open to still check SSL when using non-ssl connection |
| authenticated | EMPTY | Status of the authentication, set to True after user sucsesfully authenticates or False otherwise |
| timeOut | 30 | Time out for SMTP connections, best to set this to a low value, as the authentication script will wait till this timeout if there is an issue connecting to the server |
| newLine | \r\n | End Of Line terminator to use in SMTP comunications |
| smtpLocalHost | NONE | Local hostname for SMTP authentication, not currently used, will most likely be removed in a future revision. |
Setup Logging, not required but good for debug
$logger=new Logger('auth');
$logger->pushHandler(new StreamHandler(__DIR__.'/auth.log', LOGGER::DEBUG));
$logger->info('Auth Script Starting');
After authenticate() has been called, you can check the result of the authentication with :
$result=$auth->authenticated;
SMTP Authentication
$auth=new MailAuth($logger);
$auth->setMailServerUrl('MySMTPServerHostName');
$auth->setServerType('SMTP');
$auth->setSmtpLocalHost('MyLocalHostName');
$auth->setTimeOut(10);
$auth->setSslCheck(false);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();
SMTPS Authentication
$auth=new MailAuth($logger);
$auth->setMailServerUrl('MySMTPServerHostName');
$auth->setServerType('SMTPS');
$auth->setSmtpLocalHost('MyLocalHostName');
$auth->setTimeOut(10);
$auth->setSslCheck(true);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();
POP3 Authentication
$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyPOPServerHostName');
$auth->setServerType('POP3');
$auth->setSslCheck(false);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();
POP3S Authentication
$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyPOPServerHostName');
$auth->setServerType('POP3S');
$auth->setSslCheck(true);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();
IMAP Authentication
$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyIMAPServerHostName');
$auth->setServerType('IMAP');
$auth->setSslCheck(false);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();
IMAPS Authentication
$auth=new MailAuth($logger);
$auth->setMailServerUrl('MyIMAPServerHostName');
$auth->setServerType('IMAPS');
$auth->setSslCheck(true);
$auth->setUsername('MyUserName');
$auth->setPassword('MyPassword');
$result=$auth->authenticate();
actweb/mail-auth 适用场景与选型建议
actweb/mail-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「auth」 「smtp」 「imap」 「pop3」 「authenticate」 「pop3s」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 actweb/mail-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 actweb/mail-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 actweb/mail-auth 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP class to access an IMAP mailbox. Specifically uses the Laminas library and not the IMAP extension.
yii2 extension to read and process mails from IMAP and PHP
Laravel Multiauth package
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
IMAP client for PHP without php-imap extension dependency
This package provides a flexible way to add Role-based Permissions to Laravel 6.x
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2018-09-13