通过php和邮件头发送邮件?

通过php和邮件头发送邮件?,php,email,Php,Email,当我从php脚本发送邮件时,我是这样发送的 $to = $_POST['email']; $subject = $_POST['username'] . ' - Validate your account at example.com!'; $message = 'http://www.example.com/activate?username=' . $_POST['username'] . '&code=' . $random; $headers = 'From: noreply@e

当我从php脚本发送邮件时,我是这样发送的

$to = $_POST['email'];
$subject = $_POST['username'] . ' - Validate your account at example.com!';
$message = 'http://www.example.com/activate?username=' . $_POST['username'] . '&code=' . $random;
$headers = 'From: noreply@example.com';
当邮件发送到电子邮件时,“发件人”标题如下所示

noreply@example.com通过web87.extendcp.co.uk


有什么方法可以阻止via位显示吗?

是的,您需要实现电子邮件的发送,以便Gmail可以验证您的服务器是否有权为该域发送电子邮件。

唯一的解决方案是使用您自己的SMTP服务器,或者至少另一个SMTP服务器。。。如果您的提供商允许


是您的提供商的web服务器修改了此处的
From:
行。

尝试使用PHP中的IMAP方法

首先连接GMail imap服务器: (确保您使用的是SSL/TLS)

然后使用imap_mail()发送邮件:


希望这有帮助;)

虽然fge的答案在这里很可能是正确的,但如果标题中有“友好”名称,则您的服务器的邮件服务总是有可能不添加它:

发件人:无回复

…而不仅仅是:


来自:noreply@example.com

当你说“像这样的节目”时,你是说在Gmail里,是吗?是的,我想如果Gmail真的这么做了,大多数邮件都是一样的。我会调查一下。
$host="{imap.gmail.com:993/imap/ssl/novalidate-cert}";
$user=""; // Your GMail-account
$pass=""; // Your GMail-password
if ($mbox=imap_open($host, $user, $pass)) {
    // Connection Success
    $to = "";
    $subject = "";
    $headers = "";
    imap_mail ($to, $subject, $message, $headers)
} else {
    // Failed to connect
}