Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

php mail issue?

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

      $mailto = "redacted@hotmail.com, sales@redacted.com, kneff@redacted.com";
      $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: donotreply@LSS.com\r\n";      
      $header .= "Cc: redacted@gmail.com\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 kneff@lawnsprinklerservices.com 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?

Thanks
Payment-email.jpg
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

Cheers
Avatar of Richard Korts

ASKER

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.

Thanks
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

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).