我正在尝试为网站构建一个简单的联系表,上面写着“您的邮件已发送”。但是同时给出和错误,并且电子邮件没有收到我的收件箱。
错误是
警告:mail():中的错误消息返回路径 D:\ XXXAMP \ htdocs \ denemeson \ index.php在第38行
我在php.ini和sendmail.ini中对SMTP进行了必要的安排。
ol.js
是否有摆脱此错误并发送邮件的方法?
答案 0 :(得分:0)
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = ''; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ''; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'from@example.com';
$mail->FromName = "your name";
$mail->AddAddress($email, $name); // Add a recipient
$mail->Subject = $subject;
$mail->Body = $message;
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
确保填写空白字段。