0

这与联系表格有关。我也在尝试向用户发送电子邮件副本。

所以我想替换相同的功能,所以我if(!isset($hasError))第二次重复并更改$emailTo = $email

这是行不通的。我的问题可能与标题有关...我可以写 2 个不同的标题标签吗?

// to me        
    if(!isset($hasError)) {

        $emailTo = 'myemail@website.com';
        $subject = 'Submitted message from '.$name;
        $sendCopy = trim($_POST['sendCopy']);
        $body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
        $headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

        mail($emailTo, $subject, $body, $headers);

        $emailSent = true;
    }

//User Copy

if(!isset($hasError)) {
    $emailTo  = '$email';
    $subject = 'Thank you for Contacting';

    $body = "Here is your copy of email which you have sent us. \n\nName: $name \n\nEmail: $email \n\nComments: $comments \n\n Thank you for your email. we will get back to your soon";

    $headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

     mail($emailTo, $subject, $body, $headers);

    $UserEmailSent = true;

}
4

0 回答 0