PHPMailer - SMTP错误:无法连接到SMTP主机

时间:2015-06-23 07:59:04

标签: php mysql email phpmailer

我正在尝试使用PHPMailer发送电子邮件。当我尝试从gmail帐户发送电子邮件时,它完全正常。但是,我想从我自己的SMTP发送电子邮件,但似乎有错误。可能是什么问题呢?请帮我。谢谢。

使用smtp.gmail.com:

$mail->SMTPDebug = 3;
$mail->isSMTP();                                      
$mail->Host = 'smtp.gmail.com';                 
$mail->SMTPAuth = true;                               
$mail->Username = 'myemail@gmail.com';                 
$mail->Password = 'password';                               
$mail->SMTPSecure = 'tls';                           
$mail->Port = 587; 

使用mail.distech.com.my:

require 'PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->SMTPDebug = 3;
$mail->isSMTP();                                      
$mail->Host = 'mail.distech.com.my';                    
$mail->SMTPAuth = true;                               
$mail->Username = 'myemail@distech.com.my';                 
$mail->Password = 'password';                           
$mail->SMTPSecure = 'tls';                            
$mail->Port = 587; 

$mail->From = 'myemail@distech.com.my';
$mail->addAddress('amalina@distech.com.my');     
$mail->Subject = 'Test';
$mail->Body    = 'Test message';

if(!$mail->send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
   echo 'Message has been sent';
}

使用mail.distech.com.my

时出错
2015-06-23 06:58:45 Connection: opening to mail.distech.com.my:587, timeout=300, options=array ( ) 
2015-06-23 06:58:45 Connection: opened 
2015-06-23 06:58:45 SERVER -> CLIENT: 220-server.firstonline-server16.com ESMTP Exim 4.85 #2 Tue, 23 Jun 2015 14:58:45 +0800 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. 
2015-06-23 06:58:45 CLIENT -> SERVER: EHLO 192.168.1.20 
2015-06-23 06:58:46 SERVER -> CLIENT: 250-server.firstonline-server16.com Hello 192.168.1.20 [115.135.120.220] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP 
2015-06-23 06:58:46 CLIENT -> SERVER: STARTTLS 
2015-06-23 06:58:46 SERVER -> CLIENT: 220 TLS go ahead 
Warning: stream_socket_enable_crypto() [function.stream-socket-enable-crypto]: SSL: The operation completed successfully. in C:\xampp\htdocs\ehars\phpmailer\class.smtp.php on line 344
2015-06-23 06:58:46 SMTP Error: Could not connect to SMTP host. 
2015-06-23 06:58:46 CLIENT -> SERVER: QUIT 
Notice: fwrite() [function.fwrite]: send of 6 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. in C:\xampp\htdocs\ehars\phpmailer\class.smtp.php on line 937
2015-06-23 06:58:46 SERVER -> CLIENT: 
2015-06-23 06:58:46 SMTP ERROR: QUIT command failed: 
2015-06-23 06:58:46 Connection: closed 2015-06-23 06:58:46  SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

更新:

检查了我的phpinfo()并且已启用ssl。

enter image description here

0 个答案:

没有答案