-
Bold and font color tags not working in PHP.
Using many PHP mauals and tutorials, I have not found out how to do the following:
Below is the PHP code (which actually works, by the way, except in one area). The problem I am having is in the output (as you can see below the code). In the output, please notice that the HTML tags that are used in attempt to bold some output, using <b> & </b> ... and also to use the font color tag, using <font color=brown> and </font> ... these do not work. The remainder of the program works as intended ... except that you will notice (below the PHP code ... in the email received by the reciprients), the HTML tags are not working.
Does anyone know what I need to do. Thanks for any help.
<?php
$name = "Donald Duck";
$subject = "March 2012 Meeting Update";
$message = "Hello! ".$name." has just posted a new message with Subject: \"".$subject."\"\n"."on our <b>NameofBusiness Message Board!</b>\n\n<font
color=brown>Please visit the below URL to view the message.</font>\n\n".
"www.noname.com/NameofBusiness/Time4meeting/$newfile.\n\nAlso, you may visit the <b>NameofBusiness Web Site</b> at: www.NameofBusiness.com/.\nNOTICE:
All you need to do is CLICK on the LINKS (above) which are in blue.
End of message
";
$ae[0]="sonofwascallywabbit@yahoo.com";
$ae[1]="agal@gmail.com";
$ae[2]="bguy@gmail.com";
$ae[3]="bgal@gmail.com";
$ae[4]="cgal@gmail.com";
$ae[5]="cgal@gmail.com";
$ae[6]="dguy@gmail.com";
$ae[7]="dgal@gmail.com";
$ae[8]="eguy@gmail.com";
$ae[9]="egal@gmail.com";
$ae[10]="fguy@gmail.com";
$ae[11]="fgal@gmail.com";
$ae[12]="gguy@gmail.com";
$ae[13]="ggal@gmail.com";
$ae[14]="hguy@gmail.com";
$ae[15]="hgal@gmail.com";
$ae[16]="iguy@gmail.com";
$ae[17]="jgal@gmail.com";
$ae[18]="jguy@gmail.com";
$ae[19]="kgal@gmail.com";
$ae[20]="kguy@gmail.com";
$ae[21]="lgal@gmail.com";
$ae[22]="lguy@gmail.com";
$i = 0;
while ($i <= 22)
{
mail($ae[$i],'New NameofBusiness Message Board post',$message);
$i = $i + 1;
}
/* */
?>
************************************************
An actual email received by each recipient follows:
************************************************
--- On Sun, 2/12/12, ipw.droarkco@boscgi0204.eigbox.net <ipw.droarkco@boscgi0204.eigbox.net> wrote:
From: ipw.droarkco@boscgi0204.eigbox.net <ipw.droarkco@boscgi0204.eigbox.net>
Subject: New NameofBusiness Message Board post
To: sonofwascallywabbit@yahoo.com
Date: Sunday, February 12, 2012, 4:28 PM
Hello! Donald Duck has just posted a new message with Subject: "March 2012 Meeting Update"
on our <b>NameofBusiness Message Board!</b>
<font color=brown>Please visit the below URL to view the message.</font>
www.noname.com/NameofBusiness/Time4meeting/.
Also, you may visit the <b>NameofBusiness Web Site</b> at: www.NameofBusiness.com/.
NOTICE: All you need to do is CLICK on the LINKS (above) which are in blue.
End of message
-
-
The PHP is "working". But emails don't use HTML tags by default. So it's doing everything correctly-- it's sending symbols and displaying them as symbols. One way to prove that it is working would be to echo (print) the contents of the email into your HTML output on the page-- everything would display correctly.
If you want to display HTML in the email, there are two ways:
1. Hope that the email client guesses correctly and displays it that way. That doesn't usually happen. The only exception is that most clients will probably make something that looks like "http://...." into a link automatically. The rest (for example, bold) won't be automatic.
2. Send the email in HTML format using PHP by attaching html headers--
See example #4: http://php.net/manual/en/function.mail.php
Also, your color attribute value really should be in quotes-- color="brown". It'll work most of the time without that, but it might confuse some email clients (or browsers).
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
-
Bold and font color tags not working in PHP
Thanks and wow! ... That worked really well. I would have never thought that emails were different. It can now be seen why the reason was not easy to find ... and, hopefully I will not forget that in the future. I certainly appreciate the help.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks