Jump to content

PHP Warning: mail(): Mail header contains implicit recipients.


DustinK44

Recommended Posts

Hello.

 

I am getting the error

 

PHP Warning: mail(): Mail header contains implicit recipients. Mail not
sent. in /path/to/script.php on line 12

 

when executing the following code:

 

<?php
$email = '[email protected]';
	$headers = 'From: Support Support <[email protected]>'."\r\n".
				'Reply-To: Support Support <[email protected]>'."\r\n".
				'Content-type: text/html; charset=iso-8859-1'."\r\n".
                                        'Bcc: [email protected]' . "\r\n" .
				'X-Mailer: PHP/' . phpversion();
	$to  = '$email;
	$subject = 'Product Serial Number';
	$message = 'Hallo';

if(!mail($to, $subject, $message, $headers)) 
{
	echo 'Failed to send mail, please try again';
} else {
	echo 'OK';
}
?>

 

Anyone out there know why this is happening?

 

PHP 5.2.6 with Suhosin-Patch 0.9.6.2

 

 

Thanks!

DustinK

 

 

You've got an extra ' here:

$to  = '$email;

 

That's first thing I can notice.

 

Also, perhaps the patch you;ve got installed has this patch in it

http://www.lancs.ac.uk/~steveb/patches/php-mail-reject-implicit-recipients-patch/

 

It will not allow Bcc: field in headers.

Thanks!

 

-Forgot to add "'" in the code snippet.  (It was there originally)  :)

 

Also, perhaps the patch you;ve got installed has this patch in it

http://www.lancs.ac.uk/~steveb/patches/php-mail-reject-implicit-recipients-patch/

 

It will not allow Bcc: field in headers.

 

helps a lot!

 

 

 

Thanks!

 

-Forgot to add "'" in the code snippet.  (It was there originally)   :)

 

 

Actually it's not needed at all. Just use:

 

$to  = $email;

 

You can also change a way your headers are defined

$headers = "From: Support Support <[email protected]>\r\n
	Reply-To: Support Support <[email protected]>\r\n
	Content-type: text/html; charset=iso-8859-1\r\n
	Bcc: [email protected]\r\n
	X-Mailer: PHP/". phpversion();

 

Less quotes to care about

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.