gpt4 book ai didi

email - PHP无法发送邮件到webmail

转载 作者:可可西里 更新时间:2023-11-01 00:14:50 24 4
gpt4 key购买 nike

我在网站上有一个联系表格,如果您提交它,它将发送到网络邮件。示例:

    $isi_pesan = $message;
$additional_headers = "From: ".$email."" . "\r\n" . "Reply-To: $email";
$subject = 'Pesan untuk engineering.co.id';

$to = 'info@engineering.co.id';
// $to = 'dy_qie21@yahoo.com'; //this works

if(mail($to, $subject, $isi_pesan, $additional_headers))
echo '<div class="success-msg">Success !</div>';
else
echo '<div class="error-msg">Failed !</div>';

我收到的消息是“成功!”但我在收件箱网络邮件中什么也没有。如果 $to 不是网络邮件,则 PHP 邮件有效。那么我必须更改什么设置才能使邮件在网络邮件中正常工作?提前致谢。

最佳答案

您查看过垃圾邮件文件夹吗?看看这个 PHP 类

https://github.com/Synchro/PHPMailer

$mail = new PHPMailer;

$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->AddAddress('ellen@example.com'); // Name is optional
$mail->IsHTML(true); // Set email format to HTML

$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.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}

echo 'Message has been sent';

关于email - PHP无法发送邮件到webmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16403954/

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