Reputation: 1273
I have an issue with some emails that are being sent from my PHP application.
The emails are being received blank and they are all getting sent to a specific address. These emails are also CC'ed to an address i have control over and they are all received correctly. All the emails are sent in HTML.
I do not have control over the remote email address that these emails are sent to, but i am 100% sure they go through some kind of M$ exchange spam filter. Could it be the filter that is causing the data to go missing?
Any other thoughts on this would be great!
Upvotes: 0
Views: 147
Reputation: 352
You say all emails are sent in HTML. You may need to send plain text to go with it - to cater for those email clients that dont support HTML. http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php.
This is a copy-paste from the above link:
<?php
//define the receiver of the email
$to = '[email protected]';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
Upvotes: 2