Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

PHP email form not sending information

I've inherited an email form from a former vendor and after we've moved it to it's new server it started to malfunction. What it's supposed to do is send a verification email to the user who filled it out (does this), then send an email to [email protected] and bcc: another address (this it no longer does). Tried everything but I'm not super savvy with PHP, mostly a front-end coder, can anyone look at my code and tell me why this isn't sending properly?

PHP code:

<?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   = '[email protected]';
$to   = $posting['Email'];

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

$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);

a few hours later....

Thanks for the help guys, but it's still not sending anything, the new code looks like this:

<?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   = "[email protected], {$posting['email']}";

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

$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");
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

put

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

at the end...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...