gpt4 book ai didi

php - 邮件程序错误 : The following From address failed: Called Mail() without being connected

转载 作者:行者123 更新时间:2023-12-05 05:26:48 24 4
gpt4 key购买 nike

我正在使用 PHPMailer 使用 SMTP 发送电子邮件。我已经设置好了一切。

但最后我收到错误:
Mailer Error: The following From address failed: Email Address : Called Mail() without being connected

我知道要设置编码顺序,我也做了,但还是一样的错误。请帮我解决这个问题。

我的代码:

<?php

require 'PHPMailer.php';

error_reporting(E_ALL);
ini_set('display_errors', '1');

$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.live.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "example@outlook.com";
$mail->Password = "password";
$mail->SMTPSecure = 'tls';

$mail->From = "info@neelcomputech.com";
$mail->FromName = $name;
$mail->AddAddress("info@neelcomputech.com");

$mail->IsHTML(true);

$mail->Subject = $subject;

$mail->Body = $mail_body = "<html> <body>";
$mail_body = "<b>Hello Admin,</b><br><br>You have got email from your website.<br><br>";
$mail_body .= '<table style="" cellpadding="3">';
$mail_body .= "
<tr>
<td width='50'> <strong> Name </strong> </td>
<td width='5'> : </td>
<td> $name </td>
</tr>
<tr>
<td> <strong> Email </strong> </td>
<td> : </td>
<td> $email </td>
</tr>
<tr>
<td> <strong> Message </strong> </td>
<td> : </td>
<td> $message </td>
</tr>
</table>
</body> </html>";

if(!$mail->Send())
{
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'success';
}

?>

最佳答案

<?php

require 'PHPMailer.php';

error_reporting(E_ALL);
ini_set('display_errors', '1');

$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.neelcomputech.com"; // Your SMTP PArameter
$mail->Port = 587; // Your Outgoing Port
$mail->SMTPAuth = true; // This Must Be True
$mail->Username = "info@neelcomputech.com"; // Your Email Address
$mail->Password = "YOUR PASSWORD"; // Your Password
$mail->SMTPSecure = 'tls'; // Check Your Server's Connections for TLS or SSL

$mail->From = "info@neelcomputech.com";
$mail->FromName = $name;
$mail->AddAddress("info@neelcomputech.com");

$mail->IsHTML(true);

$mail->Subject = $subject;

$mail->Body = $mail_body = "<html> <body>";
$mail_body = "<b>Hello Admin,</b><br><br>You have got email from your website.<br><br>";
$mail_body .= '<table style="" cellpadding="3">';
$mail_body .= "
<tr>
<td width='50'> <strong> Name </strong> </td>
<td width='5'> : </td>
<td> $name </td>
</tr>
<tr>
<td> <strong> Email </strong> </td>
<td> : </td>
<td> $email </td>
</tr>
<tr>
<td> <strong> Message </strong> </td>
<td> : </td>
<td> $message </td>
</tr>
</table>
</body> </html>";

if(!$mail->Send())
{
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'success';
}

?>

在您的 smtp 身份验证中,您必须使用自己的参数。您也可以在 PHPMailer 的网站上查看其他邮件服务器的 smtp 参数: phpmailer.worxware.com/index.php?pg=tip_srvrs

关于php - 邮件程序错误 : The following From address failed: Called Mail() without being connected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23776256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com