PHP - 邮件表单内容 - 如何添加CC字段? [英] PHP - Mail Form Content - how to add CC field?

查看:381
本文介绍了PHP - 邮件表单内容 - 如何添加CC字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用这个PHP邮件脚本一段时间了,它给了我很好的...我需要问几件事。

I have used this PHP mail script for a while now and it served me well... I need to ask a few things.

现在,它只是发送电子邮件给我发送的信息。

Right now, it just sends an email to me with the information posted.

那么它只是Echo回到用户,如果它被成功提交。

then it just Echo's back to the user if it was submitted successfully or not.

如何添加CC字段以向用户发送下一步做什么方向?

How can I add a CC field to send the user some direction on what to do next?

谢谢

if (isset($_POST['submit'])) {

    if (!$_POST['name'] | !$_POST['email'])
    {
        echo"<div class='error'>Error<br />You did not fill in a required field, please review your form and correct the missing information.</div>";
    }
    else
    {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $email2 = $_POST['email2'];
        $legal = $_POST['legal'];
        $legal2 = $_POST['legal2'];
        $address = $_POST['address'];
        $address2 = $_POST['address2'];
        $city = $_POST['city'];
        $state = $_POST['state'];
        $zip = $_POST['zip'];
        $phone = $_POST['phone'];
        $comments = $_POST['comments'];



        $yoursite = "See Me Shine Models";
        $youremail = $email;

        $subject = "Website Model Form";
        $message = "$name would like you to contact them about See Me Shine Models.
            Contact PH:  $phone
            Email:  $email
            Email2: $email2
            Legal: $legal
            Legal2: $legal2
            Address: $address
            Address2: $address2
            City: $city
            State: $state
            Zip: $zip
            Phone: $phone
            Comments:  $comments";

        $email3 = "myaddress@me.com";

        mail($email3, $subject, $message, "From: $email");

        echo"<div class='thankyou'>Thank you for contacting us,<br /> we will respond as soon as we can.</div>";

    }
}


推荐答案

您需要指定标题的第四个参数:

You need to specify fourth argument of headers:

$xheaders = "";
$xheaders .= "From: Name-Here. <$email>\n";
$xheaders .= "X-Sender: <$email>\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
$xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
$xheaders .= "Cc: cc_email@example.com\n";
.................


mail($email3, $subject, $message, $xheaders);

或看本教程:

  • Send email with CC(Carbon Copy) & BCC(Blind Carbon Copy)

这篇关于PHP - 邮件表单内容 - 如何添加CC字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆