簡體   English   中英

添加電子郵件和發件人-PHP表單

[英]Add e-mail and sender - PHP form

我有聯系表。 我想將CC添加到電子郵件:abc@abc.de並更改電子郵件發件人。 目前,該服務器將我的服務器顯示為發件人,我希望收到回復表單的用戶。

你好。 我有聯系表。 我想將CC添加到電子郵件:abc@abc.de並更改電子郵件發件人。 目前,該服務器將我的服務器顯示為發件人,我希望收到回復表單的用戶。

<?php 
    session_start();
    //Ajax Questions Form 
    if(isset($_POST['email'])){

        $name = $_POST['name'];
        $email = $_POST['email'];
        $arrival = $_POST['arrival'];
        $departure = $_POST['departure'];
      ///   $adults = $_POST['adults'];
      //    $children = $_POST['children'];
     // $room = $_POST['room'];
        $requests = $_POST['requests'];
        $to = 'contact@test.camp'; //Replace with recipient email address

        $subject = 'Hotel Booking'; //Subject line for emails
        $message = 'From: '.$name."\r\n".'Email: '.$email."\r\n".'Arrival: '.$arrival."\r\n".'People: '.$departure; //."\r\n".'Adults: '.$adults."\r\n".'Children: '.$children."\r\n".'Room: '.$room."\r\n".'Requests: '.$requests;
        // Mail Functions 
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) { // this line checks that we have a valid email address
            mail($to, $subject, $message) or die('Error sending Mail'); //This method sends the mail.

            echo "Your email was sent!"; // success message
        }


    }

    //Contact Php Form 
    if(isset($_POST['contact_email'])){

        $contact_name = $_POST['contact_name'];
        $email = $_POST['contact_email'];
        $contact_message = $_POST['message'];
        $to = 'marek@gmail.com'; //Replace with recipient email address
        $subject = 'Contact Form'; //Subject line for emails
        $message = 'From: '.$contact_name."\r\n".'Email: '.$email."\r\n".'Message: '.$contact_message;
        // Mail Functions 
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) { // This line checks that we have a valid email address
            mail($to, $subject, $message) or die('Error sending Mail'); //This method sends the mail.


        }

    }





?>

php郵件功能沒有太多功能,請嘗試使用類似PHPMailer的功能 ,該功能可讓您發送更復雜的電子郵件

對於添加抄送或密件抄送或ReplyTo將標頭添加到您的電子郵件結構中:

$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

$headers[] = 'To: andreas<mail1@gmail.com>, thomas<mail2@gmail.com>';
$headers[] = 'From: from <from@gmail.com>\r\nReply-to: <ReplyTo@gmail.com>';
$headers[] = 'Cc: Cc@gmail.com';
$headers[] = 'Bcc: Bcc@gmail.com';

mail($to, $subject, $message, implode("\r\n", $headers));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM