Richard Korts
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@lawnsprinklerservice s.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
$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@lawnsprinklerservice
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Cheers
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 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);
You might also want to learn about SPF. Good links here
http://www.openspf.org/
http://en.wikipedia.org/wiki/Sender_Policy_Framework
http://tools.ietf.org/html/rfc4408
http://www.openspf.org/
http://en.wikipedia.org/wiki/Sender_Policy_Framework
http://tools.ietf.org/html/rfc4408
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).
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).