我有这段代码,一切都在我的本地服务器上运行良好。发送电子邮件时没有任何问题。
但是现在我把内容传给了webserver,我得到了这个错误...
SMTP Error: Could not connect to SMTP host.在server..correct中启用了安全套接字层?那么,问题出在哪里呢?

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "dnteiro"; // GMAIL username
$mail->Password = "xxx"; // GMAIL password发布于 2011-06-02 08:07:04
听起来你的web主机阻止了到smtp.gmail.com:465的出站连接。建议:
telnet smtp.gmail.com 465@gmail.com地址作为发件人/回复address.如果您的web主机根本不允许从其服务器进行出站中继,那么您需要考虑切换主机,如果这是您的应用程序的一个要求。
发布于 2012-01-01 11:28:38
AJ关于#2是正确的,它在:http://support.google.com/mail/bin/answer.py?hl=en&answer=78775中指定
发布于 2020-03-07 14:21:57
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.abc.co.in';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->Username = 'user name';
$mail->Password = 'password';
$mail->setFrom("from email id", "name");
$mail->addAddress("receipiant email id");
$mail->isHTML(true);
$bodycontent = 'body';
$mail->Body = $bodycontent;
if (!$mail->send()) {
echo "message has been not send", $mail->ErrorInfo;
}
else{
echo "message has been send";
}https://stackoverflow.com/questions/6209064
复制相似问题