Forum Moderators: coopster

Message Too Old, No Replies

multipart email using a class

works but different issue with variable

         

php4U

5:03 am on Mar 13, 2008 (gmt 0)

10+ Year Member



The script I am working with uses a class to send multipart/alternative email which works fine. The file where the message is composed contains the following...

$textVersion = "Hello World!";
$htmlVersion = "<font face='verdana' color='blue'><b>Hello World!</b></font>";

I changed this to...(multiple lines now above these lines for each version so the . before the = sign)
$textVersion .= $_POST['text_message'];
$htmlVersion .= $_POST['fckeditor'];

The box for each actually posts that individual message and the email is sent in both formats, but the HTML doesn't display as it appears in the editor. I've looked into several functions for HTML but nothing has worked. Most issues out there about multipart/alternative email are with email not being sent, or getting blank email...etc so my issue is a little different. I can post the additional lines of the HTML version if needed, but the text version works fine with the additional lines I added.

Additional info...
The class takes care of setting the boundary, MIME version 1.0, Content-Transfer-Encoding: base64, so I don't think it is an issue with the class file.

Any help is appreciated, thank you!
Brad

deMorte

12:10 pm on Mar 13, 2008 (gmt 0)

10+ Year Member



Could you illustrate your problem a bit more?
Does the HTML version print out anything? Or are the problems only with the visual style? Does the $htmlVersion look okay in the first example?

php4U

3:27 pm on Mar 13, 2008 (gmt 0)

10+ Year Member



sure deMorte

In the first example $htmlVersion = "<font face='verdana' color='blue'><b>Hello World!</b></font>"; it does work fine to output the bold blue text Hello World! in the email

I tested it before I tried to make a change, just to make sure it would do what I wanted.

Then I created my instance of the editor, and included it in the page which works fine. Any text I type in the editor can be edited like normal...for instance "HTML version" can be highlighted and made bold and italics. When the email is sent the HTML version only shows "HTML version" but nothing that I did extra in the editor like bolding or italics. I also changed the path to be absolute for images, and they don't show in the email either.

I am at a loss...because before adding the multipart ability and the class the following code worked fine to send HTML email only(photos worked as well)...

$msg = "<html>";
$msg .= "<head>";
$msg .= "Dear " . stripslashes(str_replace('_', ' ', $full_name)) . ",<br><br>\r\n\r\n";
$msg .= $_POST['fckeditor'];
$msg .="<br><br>----- *** Notice *** -----<br><br>\r\n\r\n";
$msg .= "If you don't wish to receive our newsletter anymore, please click the link below for safe and permanent unsubscription.<br><br>\r\n\r\n";
$msg .= "<a href='link'>link</a>";
$msg .= "</html>";

php4U

7:47 am on Mar 14, 2008 (gmt 0)

10+ Year Member



The tricky part is that if I add content in the editor and view the source I can then copy/paste that exact source into the $htmlVersion var directly

EX.
$htmlVersion .= "This was created in the <span style='font-weight: bold; font-style: italic;'>FCKeditor</span> and the <span style='color: rgb(255, 0, 0);'>source was copy/pasted</span> into the actual script to <span style='text-decoration: underline;'>see if it works that way</span>";

I tested it again, and it displayed as it should in the HTML version, and my text version which was something totally different for testing, appeared as it should have.

It seems that I am losing something when the source is set to the $_POST['fckeditor']like in my previous post.

Maybe this will help someone spot something. I am so close, but hanging up on this little issue. I'll be more than happy to post a tutorial for others that might be looking for a solution like this, but I have to get it fully corrected.

Thank you again!