PHP 联系表单不适用于 Outlook 电子邮件地址

发布于 2024-11-25 05:23:30 字数 1309 浏览 0 评论 0原文

我在 html 页面上有一个联系表格。表单数据被发送到 PHP 页面,该页面将信息发送到电子邮件地址。它适用于地址*@gmail、*@hotmail.com,但需要接收它的人已为其 website.com 地址设置了 Outlook,但它不起作用。我还需要其他设置吗?

这是 PHP 代码:

<?php

$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "Website Contact Form";
$Name = Trim(stripslashes($_POST['name'])); 
$Location = Trim(stripslashes($_POST['location'])); 
$Phone = Trim(stripslashes($_POST['phone'])); 
$Email = Trim(stripslashes($_POST['email'])); 
$Comments = Trim(stripslashes($_POST['comments'])); 



// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Location: ";
$Body .= $Location;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";


// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";

?>

I have a contact form on a html page. The form data is sent to a PHP page which sends the info to an email address. It works for addresses *@gmail, *@hotmail.com but the person who needs to receive it has Outlook set-up for their website.com address and it doesn't work. Is there another setting I need somewhere?

Here is PHP code:

<?php

$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "Website Contact Form";
$Name = Trim(stripslashes($_POST['name'])); 
$Location = Trim(stripslashes($_POST['location'])); 
$Phone = Trim(stripslashes($_POST['phone'])); 
$Email = Trim(stripslashes($_POST['email'])); 
$Comments = Trim(stripslashes($_POST['comments'])); 



// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Location: ";
$Body .= $Location;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";


// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷默言语 2024-12-02 05:23:30

这个问题经常出现。

邮件客户端(在本例中为 Outlook)很可能被配置为过滤缺少正确标头的邮件。这可能位于客户端点,也可能位于 smtp 时的服务器连接处。该问题的主旨是,基本的 php mail() 核心函数几乎普遍受到不信任,因为它可能被垃圾邮件发送者滥用。

您应该尝试使用 PHPMailer 之类的库来帮助指导您正确设置回复和其他标头。

This question comes up quite a bit.

There is a strong possibility that the mail client (in this case outlook) is configured to filter messages that lack proper headers. This could be at the client point or at the server connection at smtp time. The main thrust of the issue is that the basic php mail() core function is almost universally mistrusted due to its potential for abuse by spammers.

You should try using a library like PHPMailer to help guide you to setting the reply-to and other headers properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文