这是使用邮件函数后的代码。我在这个代码中做了什么错误,得到了错误以及如何纠正这个问题。我还在我的 gmail 帐户中启用了 IMAP,ssl_module来自 Apache 和 extension=php_openssl.dll 未注释
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()
首先,您使用的是旧版本的 PHPMailer - 获取最新版本。
基于PHPMailer提供的Gmail示例进行代码。
为了判断你是否做错了什么,你应该将你的代码作为问题的一部分发布。
设置$mail->SMTPDebug = 3;
以便您可以看到正在发生的事情 - 您可能会在 SMTP 脚本中看到更多有用的错误消息。另请参阅故障排除指南。