0

I have contact form. I'd like to add CC to e-mail: abc@abc.de and change e-mail sender. Currently it shows my server as a sender, I'd like to have reply-to form users.

Hello. I have contact form. I'd like to add CC to e-mail: abc@abc.de and change e-mail sender. Currently it shows my server as a sender, I'd like to have reply-to form users.

<?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.


        }

    }





?>
Huelfe
  • 1,776
  • 16
  • 25
Maamam
  • 1
  • 1
  • 3
    Possible duplicate of [reply-to address in php contact form](https://stackoverflow.com/questions/19007032/reply-to-address-in-php-contact-form) – Aslam Aug 02 '17 at 08:10

2 Answers2

1

The php mail function does not have much functionality try using something like PHPMailer which allows you to send more complex emails

Sean
  • 1,444
  • 1
  • 11
  • 21
0

For add CC or BCC or ReplyTo add header to your email structure :

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