在我的网站上有一个表格可以订阅我的通讯。该表单通过POST方法将用户的电子邮件发送到URL(nicetomeetyou.php)。在这个URL中,我有以下代码:
$email = $_POST['email'];
$subject = "¡Welcome to My World!";
// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: Hi' . "\r\n";
$headers .= 'Bcc: mygmail@gmail.com' . "\r\n";
ob_start();
include('welcome.php');
$htmlContent = ob_get_clean();
// Send email
if(mail($email,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Email sending fail.';
endif;
?>进行测试时,当我使用Gmail帐户订阅时,一切都是正确的。尽管如此,当我使用链接到我的gmail的电子邮件地址(hi@example.com)时,我收到包含所有标题的电子邮件消息。我甚至从0.0.0.0获得PASS的SPF。我还收到接收器的“发件人”标题。
代码有问题吗?
这是我收到的电子邮件:
Delivered-To: mygmail@gmail.com
Received: by 10.10.10.10 with SMTP id dh5csp277628obb;
Wed, 3 May 2017 14:12:03 -0700 (PDT)
X-Received: by 10.10.10.10 with SMTP id j10mr4293112iof.3.1493845922762;
Wed, 03 May 2017 14:12:02 -0700 (PDT)
Authentication-Results: mx.google.com;
spf=pass (google.com: found no external ips, assuming domain of admin4@myhost.com as permitted sender) smtp.mailfrom=admin4@myhost.com
Received-SPF: pass (google.com: found no external ips, assuming domain of admin4@myhost.com as permitted sender)
Message-ID: <590a47a2.84ec240a.4b749.7251MFETCHER_ADDED@google.com>
Received: by 10.10.10.10 with POP3 id g126mf12252590ith.0;
Wed, 03 May 2017 14:12:02 -0700 (PDT)
X-Gmail-Fetch-Info: hola@example.com 8 185.86.210.137 110 hi@example.com
DomainKey-Status: no signature
Return-Path:
X-Original-To: hi@example.com
Delivered-To: hi@example.com
Received: by server.myhost.com (Postfix, from userid 10000) id 65E9C2CA1280; Wed,
3 May 2017 23:11:05 +0200 (CEST)
To: hi@example.com
Subject: ¡Welcome to My World!
X-PHP-Originating-Script: 10000:execphp.php(27) : eval()'d code
MIME-Version: 1.0
Date: Wed, 03 May 2017 14:12:02 -0700 (PDT)
From: hi@example.com
Content-type:text/html;charset=UTF-8
From: My Web
Message-Id: <20170503211105.65E9C2CA1280@server.myhost.com>
Date: Wed, 3 May 2017 23:11:05 +0200 (CEST)
.fondo{background-image:url(https://image.example.com/565003417.jpg);background-size:cover;background-position:center 30%;}