Jump to content

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 = "test@gmail.com";
$subject = "test";
$body=$content;
$from = "webmaster@example.com";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Admin <Admin@test.com>' . "\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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.