作者 邓超

login

... ... @@ -2,11 +2,13 @@
namespace Controller;
use Lib\Imap\ImapConfig;
use Lib\Imap\ImapPool;
use Lib\Mail\Mail;
use Lib\Mail\MailFun;
use Lib\Verify;
use Model\emailSql;
use Service\SyncMail;
/**
... ... @@ -106,16 +108,23 @@ class Login {
}
$mailClient = ImapPool::get(
(new ImapConfig())
->setPassword($formData['password'])
->setHost($formData['imap'])
->setEmail($formData['email'])
);
// 进行远程登录,验证
$mailClient = (new Mail($formData['email'],$formData['password'],$formData['imap']));
// $mailClient = (new Mail($formData['email'],$formData['password'],$formData['imap']));
$login = $mailClient->login(false);
if( $login === 0){
app()->e('login_error_imap');
}elseif ($login === -1){
app()->e('email_server_error');
$login = $mailClient->login();
if(!$login->isOk()){
app()->e($login->getMessage()?'登录失败:'.$login->getMessage():'IMAP:服务器连接失败');
}
// 验证smtp登录
if(!MailFun::smtpLoginTest($formData['smtp'],$formData['email'],$formData['password'])){
app()->e('email_smtp_server_error');
... ... @@ -154,7 +163,9 @@ class Login {
if($ret){
// 同步一次文件夹
$mailClient->syncFolder(db()->value(emailSql::hasEmail($formData['email'])));
try{
(new SyncMail($formData['email'],$mailClient))->sync(false);
}catch (\Throwable $e){}
$ret = db()->first(
emailSql::first(
... ...