I want to send an email without tml form when a user has finished filling in an HTML form and then emailing information from the form. I want to do it from the same script that displays the web page that has the form.
Asked
Active
Viewed 67 times
-5
-
1If you want to add something to your question, please do so by editing the question, not by a comment. It is very difficult to read if the information is spread across multiple posts. – Klaus Gütter Dec 22 '18 at 07:41
3 Answers
2
May be it's help you see this StackAnswer
just add cc and bcc in your mail function header.
Try This code :-
<?php
if(isset($_POST['submit'])){
$to = "*********@gmail.com";
$from = "client@email.com";
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc:'.$yourmail.'\r\n';
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
?>

Daniel
- 2,621
- 2
- 18
- 34
-
here in my email emai session $vemail = $_SESSION["b"]; which i need to pass here:$from = $_POST['email']; – nsing Dec 22 '18 at 07:04
-
-
-
you write in detail what you want so we understand properly and help you perfectly.... – Dec 22 '18 at 07:36
0
<?php
if(isset($_POST['submit'])) {
$to = "********@gmail.com";
$from = email@mail.com;
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = " " . $first_name . "\n\n" . $_POST['message']; $headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2);
}
?>
0
You can add CC in your email code headers
$headers .= 'Cc: yourmail@domain.net' . "\r\n";
So your email would be added to cc so whatever mail is send to user also a copy of that mail is send to you

TarangP
- 2,711
- 5
- 20
- 41