以下是使用邮件程序功能后的代码。我在这段代码中做了什么错误得到了错误以及如何解决这个问题。我还在我的gmail帐户中启用了IMAP,来自Apache的ssl_module和扩展名= php_openssl.dll已取消注释< / p>
Here is configuration code
<?php
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
// ---------- adjust these lines ---------------------------------------
$mail->Username = "pankaj.kumar.dimple@gmail.com"; // your GMail user name
$mail->Password = "p@nkaj1390";
$mail->AddAddress("smart.developer1990@gmail.com"); // recipients email
$mail->FromName = "pankaj"; // readable name
$mail->Subject = "Subject title";
$mail->Body = "Here is the message you want to send to your friend.";
//-----------------------------------------------------------------------
$mail->Host = "smtp.gmail.com"; // GMail
$mail->Port = 465;
$mail->IsSMTP(); // use SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->From = $mail->Username;
echo "<pre>";
print_r($mail);
if(!$mail->Send())
echo "Mailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";
?>
-----------------------------------------------------------
PHPMailer Object
(
[Priority] => 3
[CharSet] => iso-8859-1
[ContentType] => text/plain
[Encoding] => 8bit
[ErrorInfo] =>
[From] => pankaj.kumar.dimple@gmail.com
[FromName] => pankaj
[Sender] =>
[ReturnPath] =>
[Subject] => Subject title
[Body] => Here is the message you want to send to your friend.
[AltBody] =>
[MIMEBody:protected] =>
[MIMEHeader:protected] =>
[mailHeader:protected] =>
[WordWrap] => 0
[Mailer] => smtp
[Sendmail] => /usr/sbin/sendmail
[UseSendmailOptions] => 1
[PluginDir] =>
[ConfirmReadingTo] =>
[Hostname] =>
[MessageID] =>
[MessageDate] =>
[Host] => smtp.gmail.com
[Port] => 465
[Helo] =>
[SMTPSecure] =>
[SMTPAuth] => 1
[Username] => pankaj.kumar.dimple@gmail.com
[Password] =>
[AuthType] =>
[Realm] =>
[Workstation] =>
[Timeout] => 10
[SMTPDebug] =>
[Debugoutput] => echo
[SMTPKeepAlive] =>
[SingleTo] =>
[SingleToArray] => Array
(
)
[LE] =>
[DKIM_selector] =>
[DKIM_identity] =>
[DKIM_passphrase] =>
[DKIM_domain] =>
[DKIM_private] =>
[action_function] =>
[Version] => 5.2.4
[XMailer] =>
[smtp:protected] =>
[to:protected] => Array
(
[0] => Array
(
[0] => smart.developer1990@gmail.com
[1] =>
)
)
[cc:protected] => Array
(
)
[bcc:protected] => Array
(
)
[ReplyTo:protected] => Array
(
)
[all_recipients:protected] => Array
(
[smart.developer1990@gmail.com] => 1
)
[attachment:protected] => Array
(
)
[CustomHeader:protected] => Array
(
)
[message_type:protected] =>
[boundary:protected] => Array
(
)
[language:protected] => Array
(
)
[error_count:protected] => 0
[sign_cert_file:protected] =>
[sign_key_file:protected] =>
[sign_key_pass:protected] =>
[exceptions:protected] =>
)
邮件程序错误:以下发件人地址失败:pankaj.kumar.dimple@gmail.com:未连接称为Mail()
答案 0 :(得分:0)
首先,您使用的是旧版本的PHPMailer - get the latest version。
将您的代码基于PHPMailer提供的gmail示例。
为了判断您是否做错了什么,您应该将代码作为问题的一部分发布。
设置$mail->SMTPDebug = 3;
以便您可以看到正在发生的事情 - 您可能会在SMTP记录中看到更多有用的错误消息。另请参阅the troubleshooting guide。