unable to send multiple bcc mail [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am trying to send Bcc mail .My mail function is working for single mail but when I am trying for bcc mail then I nothing happen .help me for possible solution .
<?php
if(isset($_POST['submit'])){
//$to = "example#com"; // this is your Email address
$to = "example#com";
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['name'];
$last_number = $_POST['number'];
$last_query = $_POST['query'];
$last_state = $_POST['state'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name ." ".$last_number." ". $last_query." ".$last_state." ". " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo $mag="Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>

You need to send Bcc in headers only like below:
headers .= "Bcc: addess1,addess2,etc \r\n";

you should try this format. also there is no bcc in your code
$headers = 'MIME-Version: 1.0' . "\\r\ ";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\ ";
$headers .= 'To: test <test#example.com>, test1 <test1#example.com>' . "\\r\ ";
$headers .= 'From: test3 <test3#example.com>' . "\\r\ ";
$headers .= 'Cc: [email]test4#example.com[/email]' . "\\r\ ";
$headers .= 'Bcc: [email]test5#example.com,test6#myserver.com,test7#gmail.com,test8#email.com[/email]' . "\\r\ ";
mail($to, $subject, $message, $headers);

Related

How can I style PHP code using HTML tags? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am triggering an email to be sent with data from a filled out form once a submit button has been clicked. The email successfully sends with the correct data, however, I am wanting to be able to apply some basic styling to the email such as some <h3> or <strong> tags. Am I able to do this within my php $message variable, and if so, what would that look like?
<?php
$to = "test#test.com"; // this is your Email address
$from = "test#test.com"; // this is the sender's Email address
$company_name = $_POST['company_name'];
$rep_name = $_POST['rep_name'];
$prod_type = $_POST['prod_type'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$subject = "New Form Submission";
$message = "New Form Submission" . "\n" . "\n" .
"Company Name: " . $company_name . "\n" .
"Representative Name: " . $rep_name . "\n" .
"Product Type: " . $prod_type . "\n" .
"Address: " . $address . "\n" .
"City: " . $city . "\n" .
"State: " . $state . "\n" .
"Zip: " . $zip . "\n" .
"Phone: " . $phone . "\n" .
"Email: " . $email . "\n";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
?>
Edit:
I have tried using ob_start() and ob_get_clean() that I found at this link Defining html code inside PHP variables but had no success
Set Content-Type: text/html header to enable HTML emails;
$headers = "From:" . $from;
$headers .= "Content-Type: text/html";
Add some HTML elements to the email;
$message = <<<EOL
<h1>Hi!</h1>
<h2>HTML Emails are awesome!</h2>
EOL;
mail($to, $subject, $message, $headers);
Small working example;
<?php
$to = '----';
$subject = 'SO test Mail';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
$message = <<<EOL
<html>
<body>
<h1>Hi!</h1>
<h2>HTML Emails are awesome!</h2>
</body>
</html>
EOL;
if ($res = (mail($to, $subject, $message, $headers))) {
echo 'OK';
} else {
echo 'Error';
var_dump($res);
}

Echoing image in php mail , showing error

I have a form when a user enters data and submits, it will go to his mail, now I am having problem with keeping my logo in the mail, below is my php code for mail
<?php
if(isset($_POST['submit'])){
$to = "contact#bolstersolutions.com"; // this is your Email address
$from = $_POST['name1']; // this is the sender's Email address
$first_name = $_POST['name2'];
$last_name = $_POST['email2'];
$last_name1 = $_POST['number1'];
$subject = "Referal";
$subject2 = "Your Friend " . $from . " Has Referred You To Us For UK Process";
$message = $from . " has refered the following student :" . "\n\n" . $first_name. "\n\n" .$last_name. "\n\n" .$last_name1;
$message2 = "Your friend " . $from . " has referred you to Bolster Solutions for UK process. We will be more than happy to process your applications, thus helping you in achieving your goals to study MS in UK." . "\n\n" . "Feel free to go to the following url for more information or else you can also call us # +91 9666999430 / 7661919191." . "\n\n" . "URL: https://consultancy.bolstersolutions.com/mail/" . "\n\n" . "Thanks and Regards." . "\n\n" . echo "<img src='https://consultancy.bolstersolutions.com/mail/assets/img/logo.png'>" ;
$headers = "From:" . $from;
$headers2 = "From: Bolster Solutions " . $to;
mail($to,$subject,$message,$headers);
mail($last_name,$subject2,$message2,$headers2);
}
?>
the following error is happening:
Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\mail\index.php
Can anyone please help me with this, thanks in advance.
Remove echo in $message2
Set headers like this
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
Then send : mail($last_name,$subject2,$message2,$headers);
There is a syntax error near: ..."\n\n" . echo "<img src.... Removing echo should solve it.

how to send email to client and one one copy to me with html form [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
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.
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.";
}
?>
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
<?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);
}
?>

could anyone tell me what's wrong with my mail form although data is posted correctly but email is not sending. Why? [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
to submit a form using email functionality:
$to = "ayush#***.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$phone = $_REQUEST['phone'];
$message = $_REQUEST['message'];
$subject = "Form submission";
$message = $name . " " . $phone . " " .$message. " wrote the following:" . "\n\n" . $_REQUEST['message'];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=isoo-8859-1\r\n";
$headers = "From:" . $from;
i am not able to send email
mail($to,$subject,$message,$headers);
header('Location: thank-you.php');
Your last header is broken.
$headers = "From:" . $from;
It requires the dot (concatenate) for it also.
$headers .= "From:" . $from;
Mail is rejected since there is no valid From and is caused by it being broken.

PHP mail() from not working [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am using mail() on my site, and the function is working, but the from address is not showing my email address, it is showing name#mailchannels.net
$ito_email = "$inameuser";
$ifrom_email = "info#mywebsite.co.za";
$isubject = "My subject";
$icomment = "Hello $inameuser,\r\n\r\n"
. " \r\n"
. "Subject: $isubjectnote"
. " \r\n"
. "Notice: $inote"
. " \r\n"
. "\r\n"
. "Many thanks";
//send email
mail($ito_email, "$isubject", $icomment, "From: Support " . $ifrom_email);
Changing
mail($ito_email, "$isubject", $icomment, "From: Support " . $ifrom_email);
to
mail($ito_email, "$isubject", $icomment, "From: Support <" . $ifrom_email . ">");
Should allow you to include a readable name as well as the FROM e-mail address.
EXAMPLE:
$email = "emailfrom#anything.com";
$headers = 'From: ' . $email . '' . "\r\n" . "Content-type: text/html;charset = windows-1250";
$subject = $email . ' - New message';
mail("your email", $subject, "email message", $headers);
$to = 'abc#xyz.com'; $subject = 'the subject';
$message = 'Message';
$headers = 'From: xyz#xyz.com' . "\r\n" .'Reply-To: xyz1#xyz.com' . "\r\n";
mail($to, $subject, $message, $headers);
OR
$headers .= $headers; Concat

Categories