好的,这是一个奇怪的,我似乎记得以前发生但不记得修复......
我的表单将发送到所有其他电子邮件帐户,但不会发送到Apple帐户(@ icloud.com,@ mac.com,@ me.com)。如果我删除所有其他电子邮件地址,并且仅将其发送到1个Apple帐户,那就可以了。但是一旦列出其他电子邮件,它就会发送给他们而不是Apple帐户(垃圾邮件,垃圾邮件等也都会被检查)。
<?php
$servername = "localhost";
$username = “***”;
$password = “***”;
$dbname = “***”;
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// prepare sql and bind parameters
$stmt = $conn->prepare("INSERT INTO guestquestionnaire (date_submitted, choice, expectations)
VALUES (:date_submitted, :choice, :expectations)");
$stmt->bindParam(':date_submitted', $date, PDO::PARAM_STR);
$stmt->bindParam(':choice', $choice);
$stmt->bindParam(':expectations', $expectations);
// insert a row
$date = date('Y-m-d H:i:s');
$choice = $_POST['choice'];
$expectations = $_POST['expectations'];
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
<?php
$my_email = "email@gmail.com";
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Check all fields for an email header.
function recursive_array_check_header($element_value)
{
global $set;
if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
}
}
recursive_array_check_header($_REQUEST);
if($set){$errors[] = "You cannot send an email header";}
unset($set);
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
// Check for a blank form.
function recursive_array_check_blank($element_value)
{
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
}
}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
// Display any errors and exit if errors exist.
if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
// Build message.
$message = '<html><body>';
$message .= "<strong>Questionnaire </strong>";
$message .= "<strong>Received: </strong>";
$message .= "<P>";
$message .= '<table rules="all" style="border: 1px solid #999;" cellpadding="7" width="100%" >';
$message .= "<tr style='background: #566890; font-size: 8pt; font-weight: bold; color: #fff;'><td colspan='3'>Prior to Arrival</td></tr>";
$message .= "<tr style='font-size: 8pt;'><td>What made you choose us? </td><td width='40%' colspan='2'>" . strip_tags($_POST['choice']) . "</td></tr>";
$message .= "<tr style='font-size: 8pt;'><td>Did we meet your expectations as advertised? If no, please state why: </td><td width='40%' colspan='2'>" . strip_tags($_POST['expectations']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
// CHANGE THE BELOW VARIABLES TO YOUR NEEDS
$to = 'email@gmail.com, email@personalemail.com, email@mac.com, email@icloud.com';
$subject = 'Questionnaire Received';
$headers = "From: email@gmail.com\r\n”;
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
(mail($to, $subject, $message, $headers))
?>
</head>
编辑:我还应该添加,如果FROM字段
$headers = "From: email@icloud.com"
是我的iCloud帐户,它通过iCloud帐户和其他非Apple帐户用户。其他iCloud帐户不会得到它。
此外,对于那些确实得到它的人,他们可以在发送给谁的列表中看到iCloud电子邮件帐户;他们只是没有得到它们。