Forum Moderators: coopster
For example,
If someone submits <b>text<b> in the module i made, the bold tags need to be replaced with something to show up in a plain text email since the <b> tags only show up in a html email.
Does anybody know what the bold tag is for a plain text email?
I tried <strong> but that didn't work.
Thanks
"To use bold face in plain text email messages: Use asterisks at the beginning and at the end of *the passage you want to put in bold face*. Some email clients will even use a bold face to display such passages."
So i have to make this thing work with plain text. Here is what my str_replace looks like:
$formating = array( "<br>", "<b>");
$html = array("", "*");
$message = "";
$body .= str_replace($formating, $html, $message);
The message is pulled from a table in a database and i fetch this through a db query.
The <br> as you can see above works..the output is just a space
However, when i replace the <b> with a * the output is in the literal format like this: *text*
In other words the output is what you see above not a bolded word
$token= strtok($message, "<b>");
$tmp = "";
while ($token !== false) {
$tmp .= "*";
$tmp .= $token;
$tmp .= "*";
$token = strtok("<b>");
}
The output looks like this: *text* instead of the actual word "text" being bold.
If you send an email with *text* in it, and open it up in, say, Mozilla Thunderbird, it will appear as text. It will always be *text* in the email you create and the output of your function, but for a small percentage of recipients with certain email clients, they get an actual bold text effect.
If you want recipients using, say, Outlook to see bold text, you need to send email to them in HTML format. In plain text, they will always see *text* within the email they receive, no matter what you do.
A side issue is that I actually use an asterisk to *emphasise* words in plain text anyway, so it could achieve it's purpose even if the text isn't made into bold ;)
As has been said there are a few clients that allow some small tricks to add formatting to plain text. The *'s will highlight a section of text even if the client doesnt display it in bold, so that is still a valid way to highlight text.
If you want proper formatting then you need to look at an HTML email. As that is the only real way you can guarantee that your format will be obeyed.
You can use very basic formatting, like line breaks, in plain text. Other than that I wouldnt rely on any proprietary formatting that may or may not be on the client.
You could always get your clients to let you know if they want plain text or html emails. Then you can do your fancy formatting for the html stuff.