php mail issue?

The following is a snippet of code from a php program that sends an email.

      $mailto = ",,";
      $subj = "On-Line Invoice Payment";
      $totpmnt = 0;
      $body = "Customer $custname has made on on-line payment as follows:\n";
      for ($i = 0; $i < $ni; $i++) {
// fix this regarding "blank" invoice #
            if ($paids[$i] != "") {
                  $pdfmt = sprintf($paids[$i]);
                  $body = $body . "Invoice Number: $invnos[$i] - Payment Amount: \$$pdfmt\n";
                  $totpmnt = $totpmnt + $paids[$i];
      $totf = sprintf("%01.2f", $totpmnt);                  
      $body = $body . "\nThe total amount paid was: \$" . $totf. "\n";
      $header  = "MIME-Version: 1.0\r\n";
      $header .= "Content-type: text/html; charset=iso-8859-1\r\n";
      $header .= "From:\r\n";      
      $header .= "Cc:\r\n";

      $mres = mail($mailto, $subj, $body, $header);

In a test this AM, I executed this code; I am the Cc at the end of $header. I received the email; see attached.

The recipient says she received the email; the others did not (they claim).

Subsequent to that, I manually composed an email to the 3 emails in the $mailto variable. It was received by all.

Is there anything wrong with the formatting that could be causing this failure?

Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Quite probably the email was put into the junk or spam folders.  Automatically generated email has a "smell" that most modern mail programs can detect.  You should tell them to white-list the sending domain and the sending "from" address.
Dave BaldwinFixer of ProblemsCommented:
PHP mail() is kind of crippled.  And I would expect anything from 'donotreply', especially with multiple 'To:' addresses to be deleted by Hotmail.  Many mail services will not accept email from an address that can't be verified like ''.

Your best option is to send individual emails to each recipient from a verifiable email address.  I don't know why you are sending invoices from a 'donotreply' anyway.  That isn't business-like to me.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marco GasiFreelancerCommented:
Personally, I use PhpMailer to send mutliple emails and it works fine. In addition is very well documented and you find several tutorial on the web.

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Richard KortsAuthor Commented:
To Dave Baldwin,

The specific email in question is being sent to email addresses at the company (not the customer) when a payment is made by a customer. But I will do exactly as you suggest.

Dave BaldwinFixer of ProblemsCommented:
The email servers aren't inside the company so that doesn't change the possible problems.  And you don't have to do the entire email 3 times.   Just use 3 different 'To:' addresses.

$mres1 = mail($mailto1, $subj, $body, $header);
$mres2 = mail($mailto2, $subj, $body, $header);
$mres3 = mail($mailto3, $subj, $body, $header);

Open in new window

Ray PaseurCommented:
Julian HansenCommented:
Any particular reason you are using an HTML mime type in your message header?

You don't seem to be using any HTML markup - sending the mail as text might also have an effect (in addition to the other avice above).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.