Alan
Alan

Reputation: 111

send private copy of autoresponder mail

I have some php here that works great. I want a mail to be sent to the user who submits a form and I also want a copy of that mail sent to myself but I don't want my email address to be made available to the user.

Here's the php I'm using to govern the mail sending ...

$to  = '[email protected]' . ', ';
$to .= $email;
$subject = 'xxxx'; 
$message = "Thank you for submitting the form.";

$headers = "From: [email protected]\r\nReply-To: [email protected]";
$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";

When the code is parsed emails are duly sent to both the users submitted email ($email) and the address I enter in the first $to variable however the user can see the email address I enter as another recipient when they receive the email. Anyone know how I can get around this? Any help will be much appreciated. Thanks.

Upvotes: 0

Views: 62

Answers (1)

IMSoP
IMSoP

Reputation: 97948

Use a BCC header instead of an additional To in your $headers string. It stands for "Blind Carbon Copy", and instructs the mail server to duplicate the mail to extra recipients, but remove that header from the original copy, so the main recipients can't know it was there.

Upvotes: 1

Related Questions