PHP and sending mail formatting
I w开发者_JAVA技巧as wondering how do I format my mail when I use PHP to send it. How do I add new lines, tab space, bold letters and words and so on?
You can add newlines, tabs, and spaces, by simply including newlines, tabs, and spaces in your message.
mail('someone@example.com', 'A Message', "Hello,\nHow \t\t\t\t\t are you?\n\nSincerely, PHP.");
If you want to send a formatted message with bold, however, you'll have to format the message as HTML.
mail('someone@example.com', 'A Message', "<html><head>...</head><body>Hello,<br /><strong>How</strong> are you?<br /><br />Sincerely, PHP.</body></html>");
Don't forget that whitespace like tabs and newlines don't really do anything in HTML (except provide a single space between words), so if you want whitespace in a formatted message you'll have to use HTML tags like <br />
and CSS properties like margin
and padding
.
you would use something like this
echo" This is my formated email \n and this is a new like. you can also use <br /><br />
";
精彩评论