作者 邓超

smtp

@@ -173,7 +173,9 @@ class MailFun { @@ -173,7 +173,9 @@ class MailFun {
173 $mail->SMTPAuth = true; //Enable SMTP authentication 173 $mail->SMTPAuth = true; //Enable SMTP authentication
174 $mail->Username = $email['email']; //SMTP username 174 $mail->Username = $email['email']; //SMTP username
175 $mail->Password = base64_decode($email['password']); //SMTP password 175 $mail->Password = base64_decode($email['password']); //SMTP password
  176 + if($smtp['port']!=25){
176 $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption 177 $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
  178 + }
177 $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` 179 $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
178 $mail->CharSet = 'utf-8'; 180 $mail->CharSet = 'utf-8';
179 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE; 181 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE;
@@ -317,7 +319,9 @@ class MailFun { @@ -317,7 +319,9 @@ class MailFun {
317 $mail->SMTPAuth = true; //Enable SMTP authentication 319 $mail->SMTPAuth = true; //Enable SMTP authentication
318 $mail->Username = $email; //SMTP username 320 $mail->Username = $email; //SMTP username
319 $mail->Password = $password; //SMTP password 321 $mail->Password = $password; //SMTP password
  322 + if($smtp['port']!=25){
320 $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption 323 $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
  324 + }
321 $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` 325 $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
322 $mail->CharSet = 'utf-8'; 326 $mail->CharSet = 'utf-8';
323 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE; 327 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE;
@@ -352,18 +356,25 @@ class MailFun { @@ -352,18 +356,25 @@ class MailFun {
352 $host = ltrim($host,'/'); 356 $host = ltrim($host,'/');
353 $arr = explode(":",$host); 357 $arr = explode(":",$host);
354 if(str_contains($host, '//')){ 358 if(str_contains($host, '//')){
355 - return [ 359 + $data = [
356 'host' => $arr[0].':'.$arr[1], 360 'host' => $arr[0].':'.$arr[1],
357 'port' => empty($arr[2]) ? $port : $arr[2], 361 'port' => empty($arr[2]) ? $port : $arr[2],
358 ]; 362 ];
359 }else{ 363 }else{
360 364
361 - return [ 365 + $data = [
362 'host' => $ssl.$arr[0], 366 'host' => $ssl.$arr[0],
363 'port' => empty($arr[1]) ? $port : $arr[1], 367 'port' => empty($arr[1]) ? $port : $arr[1],
364 ]; 368 ];
365 } 369 }
366 370
  371 + if($data['port'] == 25){
  372 + $data['host'] = explode('//',$data['host'],2);
  373 + $data['host'] = $data['host'][1];
  374 + }
  375 +
  376 + return $data;
  377 +
367 } 378 }
368 379
369 380