PHP Classes

Cannot create html message

Recommend this page to a friend!

      MIME E-mail message sending  >  MIME E-mail message sending package blog  >  How Can PHP Send Emai...  >  All threads  >  Cannot create html message  >  (Un) Subscribe thread alerts  
Subject:Cannot create html message
Summary:Following the instructions but nothingt comes
Messages:4
Author:Shumit Rehman
Date:2008-07-06 17:11:47
Update:2008-07-08 04:26:20
 

  1. Cannot create html message   Reply   Report abuse  
Picture of Shumit Rehman Shumit Rehman - 2008-07-06 17:11:47
Hi

I am following your documentation in the Usage section but I keep getting the error message "it was added a part without a body PART". Ive no idea what I am doing wrong - ps just using text works fine.
many thanks,Shumit

here's my code:

$message="Some text";
$message_object = new email_message_class();
$message_object->SetHeader("From","me@comp.com");
$message_object->SetHeader("Subject","subject");
$message_object->SetHeader("To","you@yours.com");

$message_object->AddPlainTextPart($message_object->WrapText($message,75));
$hmtl= "<html><body><h1>Try this</h1></body></html>";
$message_object->AddHTMLPart($html);
$err=$message_object->Send();

  2. Re: Cannot create html message   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-06 23:07:51 - In reply to message 1 from Shumit Rehman
You cannot add multiple messages parts individually. You need to add multipart part to enclose the text and HTML parts you want to add.

Take a look at the test_simple_html_mail_message.php example script.

  3. Re: Cannot create html message   Reply   Report abuse  
Picture of Shumit Rehman Shumit Rehman - 2008-07-07 09:29:02 - In reply to message 2 from Manuel Lemos
All clear now - the documentation was slightly confusing as it appears that u just need to use addthehtmlpart and it should be ok.

thanks!

  4. Re: Cannot create html message   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-08 04:26:20 - In reply to message 3 from Shumit Rehman
In theory, you can send HTML messages just with a single HTML part, but if you do that many e-mail systems like Hotmail will consider it as SPAM.

So, multipart/alternative is the way to do it right, just like regular e-mail programs.