我尝试使用php邮件程序,但错误如下。
SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate. Message could not be sent.
Mailer Error: SMTP Error: Could not authenticate.
和我的代码
<?php
require("class.phpmailer.php")
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPDebug = 2;
$mail->Username = "admin@xxxxxxxxxxxx.in";
$mail->Password = "xxxxxxxx";
$mail->From = "admin@xxxxxxxxxxxx.in";
$mail->FromName = "Mailer";
$mail->AddAddress("xxxx@yahoo.co.in", "mine");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$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. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
答案 0 :(得分:19)
由于SSL端口错误,我得到了这个。
SSL = 465 TLS = 587
请参阅: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
答案 1 :(得分:14)
某些服务器(尤其是共享主机)会阻止您使用SSL与SMTP,我曾遇到同样的问题。
如果可以,请更改主机,尝试使用默认的PHP mail()函数或通过其他不需要SSL的邮件服务器发送,例如25号港口不是465。
像AuthSMTP这样的东西对于备用邮件服务器来说是最好的选择。
答案 2 :(得分:9)
我遇到了同样的问题,似乎我们有
设置SMPTSecure值。
首先,我将端口从465更改为587并添加:
$ mail-&gt; SMTPSecure =“tls”;
它有效:)
答案 3 :(得分:5)
如果您在localhost中工作,只需转到 PHP扩展程序并启用或检查 php_openssl 它将能够访问SSL端口。
答案 4 :(得分:3)
试试这段代码
require 'PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
//$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
//$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 465;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'ssl';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "admin@gmail.com";
//Password to use for SMTP authentication
$mail->Password = "admin123";
$mail->setFrom('admin3@gmail.com', 'development'); //add sender email address.
$mail->addAddress('admins@gmail.com', "development"); //Set who the message is to be sent to.
//Set the subject line
$mail->Subject = $response->subject;
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->Body = 'Name: '.$data['name'].'<br />Location: '.$data['location'].'<br />Email: '.$data['email'].'<br />Phone:'.$data['phone'].'<br />ailment: '.$data['ailment'].'<br />symptoms: '.$data['symptoms'];
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.gif');
//$mail->SMTPAuth = true;
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
答案 5 :(得分:2)
可能是因为防火墙?
如果您无法登录Google Talk, 或者你收到一个错误 说,无法验证 服务器,检查你是否有个人 安装防火墙软件,或者如果 您的计算机位于代理服务器后面 这需要用户名和密码。
http://www.google.com/support/talk/bin/answer.py?hl=en&answer=30998
答案 6 :(得分:2)
我为多个客户端使用相同的脚本,并且在部署到Amazon EC2云提供程序(例如Openshift)时遇到此问题。
这些是phpmailer中经过试验和测试的设置: $ mail-&gt; SMTPSecure =&#34; tls&#34 ;; //为servier设置前缀 $ mail-&gt; Host =&#34; smtp.gmail.com&#34 ;; //将GMAIL设置为SMTP服务器 $ mail-&gt; Port = 587;
&#39;但&#39; Google将这些服务视为反垃圾邮件&#39; /政治机动,这引起了我的注意,因为它在本地工作,在大多数托管服务提供商,当他们不接受来自你的主机DNS / IP的出站消息时,你无能为力。接受它并继续寻找另一个smtp服务器来路由消息。
答案 7 :(得分:2)
出现同样的问题,将opencart邮件设置中的端口号更改为587并正常工作
答案 8 :(得分:1)
不确定,但请尝试$mail->Host = "smtp.gmail.com" =>$mail->Host = "smtp.google.com"