且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

联系表单不发送发件人电子邮件

更新时间:2023-02-25 12:16:27

chris85 在评论中回答了问题:

chris85 answered the question in the comments:


来自 $ comments 不应该是 $ senderEmail

然而,这不是那么简单。您不能从电子邮件地址中选择任何,并期望它可以正常工作。如果您尝试欺骗地址,电子邮件客户端很可能会垃圾邮件。

However, it's not quite that simple. You can't just pick any from email address and expect it to work. The email client will most likely spam your emails if you try to spoof the from address.

每当您更改标题,你还需要更改回复到标题,在你的情况下,你应该把头作为您服务器上的电子邮件地址之一,只将回复标头更改为任何用户输入的内容。这样,您的邮件更有可能不会被垃圾邮件发送,因为它看起来并不像你想偷偷摸摸。

Whenever you change the From header you also need to change the reply-to header, in your case, You should probably put the From header as one of the email addresses on your server and only change the reply-to header to whatever the user in-putted. That way your messages are more likely to not be spammed because it doesn't look like you're trying to be sneaky.

另一种选择是使用一个简单的库照顾所有这一切。

Another option is to use a simple library to take care of all this for you.

这是一个非常简单的一个我写的: http://geneticcoder.blogspot.com/2014/08/wrapper-for-phps-mail-function.html

Here's a real simple one I wrote: http://geneticcoder.blogspot.com/2014/08/wrapper-for-phps-mail-function.html