向用户发送联系表格副本到他的电子邮箱

时间:2013-09-27 20:11:47

标签: php email

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

所以我想替换相同的功能,所以我第二次重复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;

}

0 个答案:

没有答案