开发者

PHP - Mail Form Content - how to add CC field?

开发者 https://www.devze.com 2023-01-23 04:37 出处:网络
I have used this PHP mail script for a while now and it served me well... I need to ask a few things.

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.

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

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

thanks

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

Or see this tutorial:

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

精彩评论

暂无评论...
验证码 换一张
取 消