...
|
...
|
@@ -45,8 +45,47 @@ class Login { |
|
|
app()->e('smtp_verify_error');
|
|
|
}
|
|
|
|
|
|
// 是否是shopk那边已添加的邮箱,进行代理
|
|
|
$status = file_get_contents('https://oa.shopk.com/fob-check-email/'.$formData['email']);
|
|
|
// 存在 就把服务器替换为代理服务器
|
|
|
if($status=='exist'){
|
|
|
/**
|
|
|
* 代理功能 去shopk检查邮件是否被添加到shopk了。
|
|
|
* 如果添加到shopk了就把请求地址替换成shopk的服务器地址
|
|
|
* 由shopk代理
|
|
|
* 避免出现换ip登录的情况而被封号
|
|
|
*/
|
|
|
$callHost = function (string $host,int $prot){
|
|
|
$host = parse_url($host);
|
|
|
if(empty($host['host'])){
|
|
|
$host = $host['path'].':'.$prot;
|
|
|
}else{
|
|
|
$host = $host['host'].':'.(empty($host['port'])?$prot:$host['port']);
|
|
|
}
|
|
|
return $host;
|
|
|
};
|
|
|
|
|
|
$formData['imap'] = $callHost($formData['imap'],993);
|
|
|
$formData['smtp'] = $callHost($formData['smtp'],465);
|
|
|
// 服务器代理到shopk服务器上面
|
|
|
$proxy = [
|
|
|
'imap.gmail.com:993' => '43.154.117.107:10086',
|
|
|
'smtp.gmail.com:465' => '43.154.117.107:10087'
|
|
|
];
|
|
|
// 是否存在代理
|
|
|
if(empty($proxy[$formData['imap']]) || empty($proxy[$formData['smtp']]) ){
|
|
|
app()->e('请联系站点管理员添加代理');
|
|
|
}
|
|
|
// 替换为代理服务器
|
|
|
$formData['imap'] = $proxy[$formData['imap']];
|
|
|
$formData['smtp'] = $proxy[$formData['smtp']];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// 进行远程登录,验证
|
|
|
$mailClient = (new Mail($formData['email'],$formData['password'],$formData['imap']));
|
|
|
$mailClient->client->debug(true,'echo');
|
|
|
$login = $mailClient->login(false);
|
|
|
if( $login === 0){
|
|
|
app()->e('login_error_imap');
|
...
|
...
|
|