PHP Mail error

Robert Granlund
Robert Granlund used Ask the Experts™
I am sending PHP mail but I am getting an error from the server and the emails are being Quarantined.

Here is what I have:
$headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
	$headers .= 'To: '.$to."\r\n";
	$headers .= 'From: '.$from."\r\n".' Return-Path: '.$from."\r\n";
	@mail($to, $subject, $message, $headers);

Open in new window

These are two of the errors.  Please look at the return path.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Year 2008
Top Expert 2008
>> ' Return-Path: '
try getting rid of the space between the apostrophe and the "R":
'Return-Path: '
Most Valuable Expert 2011
Top Expert 2016
Looks like you want to remove the "To:" from the headers, too.  It goes into the mail() function call, not in the headers.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Yes to both of those suggestions.  Email header items must start at the first character on the line and your email server is complaining about duplicate 'To:' lines.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial