这是我的代码:
我尝试更改端口和安全连接类型为"TSL"和"SSL",但没有效果。我已经查看了现有的答案,但都没有解决问题。有什么建议吗?谢谢。
我启用了SMTP调试器,它显示:"Connection: opening to ssl://send.one.com:465, t=300, opt=array ( ) 2014-12-15 15:46:40 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2014-12-15 15:46:40 SMTP connect() failed"。
require 'phpmailertesting/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'send.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myemailhidden'; // SMTP username
$mail->Password = 'mypasswordhidden'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = 'myemailhidden';
$mail->FromName = 'My Name';
$mail->addAddress('example@example.com'); // Name is optional
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
我尝试更改端口和安全连接类型为"TSL"和"SSL",但没有效果。我已经查看了现有的答案,但都没有解决问题。有什么建议吗?谢谢。
我启用了SMTP调试器,它显示:"Connection: opening to ssl://send.one.com:465, t=300, opt=array ( ) 2014-12-15 15:46:40 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2014-12-15 15:46:40 SMTP connect() failed"。
telnet send.one.com 465
对我有效。尝试将$mail->SMTPSecure
行完全删除,看看是否有效? - sjagr