Last active
June 28, 2024 13:53
-
-
Save JackyCZJ/7f54758650875656228de86770d24e8a to your computer and use it in GitHub Desktop.
让Discuz!支持starttls发送邮件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//在131行处添加 | |
if ($_G['setting']['mail']['port'] == '587'){ | |
//Need to start TLS | |
fputs($fp, "STARTTLS\r\n"); | |
$lastmessage = fgets($fp, 512); | |
if(substr($lastmessage, 0, 3) != 220) { | |
fputs($fp, "QUIT\r\n"); | |
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) STARTTLS - $lastmessage", 0); | |
return false; | |
} | |
if (function_exists('stream_socket_enable_crypto')) { | |
stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); | |
} | |
fputs($fp, ($_G['setting']['mail']['auth'] ? 'EHLO' : 'HELO')." $host\r\n"); | |
$lastmessage = fgets($fp, 512); | |
if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) { | |
fputs($fp, "QUIT\r\n"); | |
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) HELO/EHLO - $lastmessage", 0); | |
return false; | |
} | |
while(1) { | |
if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) { | |
break; | |
} | |
$lastmessage = fgets($fp, 512); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment