1

Currently this is how the headers look like. What should I do if I want to add a bcc. Thanks for the help. Below is what the code looks like.

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>
user3377272
  • 51
  • 1
  • 1
  • 3
  • 3
    What did you not understand in the example of the [manual](http://www.php.net/manual/en/function.mail.php)? – Markus Malkusch Mar 04 '14 at 02:36
  • even for simple mail sending a library is the way to go, –  Mar 04 '14 at 03:31
  • sorry felt like a spoiled brat here, im really not a programmer, but thanks to carl and your advice about the manual. i didnt manage to check from there. next time though. – user3377272 Mar 05 '14 at 01:39

2 Answers2

16

You would add this in the headers:

'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'Bcc: someone@example.com' . "\r\n" . 
'X-Mailer: PHP/' . phpversion();

As shown on the docs at PHP.net

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
  • 1
    If I want multiple BCCs, should I use commas? Another header entry? Semi colons? – Jack Nov 23 '16 at 09:48
  • 1
    you just add another Bcc entry like described above. 'Bcc: someone@example.com' . "\r\n" . 'Bcc: someone_else@example.com' . "\r\n" . – Cristian Oana Apr 21 '17 at 19:48
-1

This is how my Mail function looks, with Bcc and cc

//Send email
Mail::send('emails.contactus',
     array(
            'name'         => $request->get('fname'),
            'designation'  => $request->get('jobtitle'),
            'orgn'         => $request->get('orgn'),
            'phone'        => request('countrycode')
        ), 
        function($message) use ($request)
        {
            $message->from('hello@xxxx.com','Name');
            $message->to('support@xxx.com', 'Name')->subject('New Enquiry from Website');
            $message->cc('rajiv@xxx.me');
            $message->Bcc('rajiv@xxx.me');
        });
    
hackernewbie
  • 1,606
  • 20
  • 13