We help IT Professionals succeed at work.

PHP Mail error

Robert Granlund
on
124 Views
Last Modified: 2017-03-12
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:
<?php
$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.
Console_2017-03-08_15-15-17.png
Console_2017-03-08_15-21-41.png
Comment
Watch Question

CERTIFIED EXPERT
Expert of the Year 2008
Top Expert 2008
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions