-2

我从以前的供应商那里继承了一份电子邮件表格,在我们将它移到它的新服务器后,它开始出现故障。它应该做的是向填写它的用户发送一封验证电子邮件(这样做),然后发送一封电子邮件到warranty@mydomain.com 和密件抄送:另一个地址(它不再这样做)。尝试了一切,但我对 PHP 不是超级精通,主要是前端编码器,任何人都可以查看我的代码并告诉我为什么无法正确发送?

PHP代码:

<?php
header("location: http://www.anatomicglobal.com/warranty/regthanks.html");

$posting = array(
    'Name'      =>  $_POST['Name'],
    'Email'     =>  $_POST['Email'],
    'Phone'     =>  $_POST['Phone'],
    'Address'   =>  $_POST['Address'],
    'City'      =>  $_POST['City'],
    'State'     =>  $_POST['State'],
    'Province'  =>  $_POST['Province'],
    'Zip'       =>  $_POST['Zip'],
    'Product'   =>  $_POST['check'][0],
    'Size'      =>  $_POST['size'][0],
    'Mattress Model Name'   =>  $_POST['MattressModeName'],
    'Mattress Model Number' =>  $_POST['MattressModeNo'],
    'Serial Number' =>  $_POST['SerialNumber'],
    'Store Name'    =>  $_POST['StoreName'],
    'Purchase Month'=>  $_POST['Month'],
    'Purchase Day'  =>  $_POST['Day'],
    'Purchase Year' =>  $_POST['Year']
);

$decide = $_POST['decide'];

$subject  = 'Eco Memory Foam - Warranty Registration';
$to   = 'warranty@anatomicglobal.com';
$to   = $posting['Email'];

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: Anatomic Global <warranty@anatomicglobal.com>' . "\r\n";
$headers .= 'From: ecomemoryfoam.com <warranty@anatomicglobal.com>' . "\r\n";
$headers .= 'Reply-To: ' . $posting['Email'] . "\r\n";
$headers .= 'bcc: Hollyce Weber <hweber@anatomicglobal.com>' . "\r\n";

$message  = '<html>';
$message .= '<head><title>Eco Memory Foam - Warranty Registration</title></head><body>';
$message .= '<h1>Eco Memory Foam - Warranty Registration</h1>';
$message .= '<p><strong>Warranty Registration</strong> submission successful, please keep for your records.</p>
';
$message .= '<p>Below is the submitted information at: <strong>' . strftime("%B %d %Y - %H:%M:%S", time()) . '</strong></p>';
$message .= '<dl>';

foreach ($posting as $field => $value) {
$message .= '<dt>';
$message .= '<dd><b>' . $field . '</b>:&nbsp;&nbsp;' . $value . '</dd>';
$message .= '</dt>';
};

$message .= '<dt>Decide to Purchase This Product?</dt>';
$message .= '<dd>Customer Selected:<ul>';
foreach ($decide as $field => $value) {
$message .= '<li>' . $value . '</li>';
};
$message .= '</ul></dd>';

$message .= '</dl>';
/**$message .= '<p>You can reply to the submitter by replying to this email (if they gave you a valid email address).</p></body></html>';**/

mail($to, $subject, $message, $headers);

几个小时之后....

感谢大家的帮助,但它仍然没有发送任何东西,新代码如下所示:

<?php

$posting = array(
    'Name'      =>  $_POST['Name'],
    'Email'     =>  $_POST['Email'],
    'Phone'     =>  $_POST['Phone'],
    'Address'   =>  $_POST['Address'],
    'City'      =>  $_POST['City'],
    'State'     =>  $_POST['State'],
    'Province'  =>  $_POST['Province'],
    'Zip'       =>  $_POST['Zip'],
    'Product'   =>  $_POST['check'][0],
    'Size'      =>  $_POST['size'][0],
    'Mattress Model Name'   =>  $_POST['MattressModeName'],
    'Mattress Model Number' =>  $_POST['MattressModeNo'],
    'Serial Number' =>  $_POST['SerialNumber'],
    'Store Name'    =>  $_POST['StoreName'],
    'Purchase Month'=>  $_POST['Month'],
    'Purchase Day'  =>  $_POST['Day'],
    'Purchase Year' =>  $_POST['Year']
);

$decide = $_POST['decide'];

$subject  = 'Eco Memory Foam - Warranty Registration';
$to   = "warranty@anatomicglobal.com, {$posting['email']}";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: Anatomic Global <warranty@anatomicglobal.com>' . "\r\n";
$headers .= 'From: ecomemoryfoam.com <warranty@anatomicglobal.com>' . "\r\n";
$headers .= 'Reply-To: ' . $posting['Email'] . "\r\n";
$headers .= 'bcc: Hollyce Weber <hweber@anatomicglobal.com>' . "\r\n";

$message  = '<html>';
$message .= '<head><title>Eco Memory Foam - Warranty Registration</title></head><body>';
$message .= '<h1>Eco Memory Foam - Warranty Registration</h1>';
$message .= '<p><strong>Warranty Registration</strong> submission successful, please keep for your records.</p>
';
$message .= '<p>Below is the submitted information at: <strong>' . strftime("%B %d %Y - %H:%M:%S", time()) . '</strong></p>';
$message .= '<dl>';

foreach ($posting as $field => $value) {
$message .= '<dt>';
$message .= '<dd><b>' . $field . '</b>:&nbsp;&nbsp;' . $value . '</dd>';
$message .= '</dt>';
};

$message .= '<dt>Decide to Purchase This Product?</dt>';
$message .= '<dd>Customer Selected:<ul>';
foreach ($decide as $field => $value) {
$message .= '<li>' . $value . '</li>';
};
$message .= '</ul></dd>';

$message .= '</dl>';
/**$message .= '<p>You can reply to the submitter by replying to this email (if they gave you a valid email address).</p></body></html>';**/

mail($to, $subject, $message, $headers);

header("location: http://www.anatomicglobal.com/warranty/regthanks.html");
4

2 回答 2

1

header("location: http://www.anatomicglobal.com/warranty/regthanks.html");

在最后...

于 2013-03-13T15:39:14.630 回答
0

在您的代码中,您拥有它,因此它只会将电子邮件发送到一个地址。在这里你正在建立你的to地址:

$to   = 'warranty@domain.com';
$to   = $posting['Email'];

如果您注意到,您将地址设置为您的地址,然后用发布的电子邮件覆盖它。然后您继续将其通过电子邮件发送到一个地址

mail($to, $subject, $message, $headers);

您需要这样构建地址:

$to = "warranty@domain.com, {$posting['email']}";

这将具有以下值:

"warranty@domain.com, other@domain.com"
于 2013-03-13T16:05:15.057 回答