从默认电子邮件地址(而不是我指定的电子邮件地址)发送的php邮件

时间:2020-11-03 23:00:54

标签: php email email-headers

我有一个将数据发送到以下脚本的表单。它应该从表单的电子邮件地址中指定的人发送消息。相反,我是从托管公司的一个奇怪的电子邮件地址获得的。我已经一遍又一遍地检查了php,无法找到问题所在。电子邮件确实发送...只是从错误的地址发送的邮件...

<?
// set recipient email
$mymail = "thelamp.website@yahoo.com";

// get information from form
$name = $_POST['firstname'] . " - " . $_POST['lastinitial'];
$email = $_POST['emailaddress'];
$multiplemail = $mymail . ", " . $email;
$message = $_POST['testimonial'];
$message = wordwrap($message, 200, "\r\n");
$subject = "Testimonial Submission:  ";
date_default_timezone_set('US/Eastern');
$body = "Date:  " . date('m-d-Y') . " - Time:  " . date('h:i:s A e') . "\n Name:  " . $name . "\n eMail:  <" . $email . "> \n wrote:  \n" . $message;
$headers = "To:" . $email . ", " . $mymail . ", From:" . $email;

// check the eMail!
$emailB = filter_var($email, FILTER_SANITIZE_EMAIL);
if (filter_var($emailB, FILTER_VALIDATE_EMAIL) === false || $emailB != $email)
    {

// Display error message!
        echo "This eMail adress that you entered in the form is invalid!  Please go back and enter a correct eMail address!";

// Exit the checking scriptlet!
        exit(0);
    }
else
    {
        if(!mail($multiplemail, $subject, $body, $headers))
            {
// Testimonial was NOT sent
                die ("Testimonial could not be sent!  Please try again later!");
            }
        else
            {
// Testimonial was successfully sent
                ?><meta http-equiv="refresh" content="0; URL=thankyou.html"><?
            }
    }

?>

您能给我的任何帮助将不胜感激。预先感谢。

0 个答案:

没有答案