Jump to content

email with html elements not sent


php_begins

Recommended Posts

Hi I am having trouble sending emails with html content.

My $content variable is defined as follows:

$content='<html><body> lots of html data with tables and rows here </body></html>';

But when I execute the code, it says 'Mail sent', but I do not get any email.

if i just define $body="hello", it sends me the email.

Here is my code to send the email

<?
$to = "[email protected]";
$subject = "test";
$body=$content;
$from = "[email protected]";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Admin <[email protected]>' . "\r\n";
// Send email
if(mail($to,$subject,$body,$headers))
{
  // Inform the user
  echo "Your email has been sent";
}
else
{
  echo "MAIL not sent";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/248130-email-with-html-elements-not-sent/
Share on other sites

Sometimes mail sent via the built in smtp protocol in PHP has some problems. Make sure of a few things

 

A.)Your SMTP server is actually up and running

B.)You check your spam folder and such

C.)Your email address/info is correct

D.)Your header information is formed correctly.

 

D is especially important as some email providers dont allow emails with malformed headers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.