user3377272
user3377272

Reputation: 51

Add bcc PHP mail function

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

Upvotes: 1

Views: 23826

Answers (2)

hackernewbie
hackernewbie

Reputation: 1712

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('[email protected]','Name');
            $message->to('[email protected]', 'Name')->subject('New Enquiry from Website');
            $message->cc('[email protected]');
            $message->Bcc('[email protected]');
        });
    

Upvotes: -1

Cjmarkham
Cjmarkham

Reputation: 9681

You would add this in the headers:

'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'Bcc: [email protected]' . "\r\n" . 
'X-Mailer: PHP/' . phpversion();

As shown on the docs at PHP.net

Upvotes: 16

Related Questions