简体   繁体   English

PHP和发送邮件格式

[英]PHP and sending mail formatting

I was wondering how do I format my mail when I use PHP to send it. 我想知道当我使用PHP发送邮件时如何格式化邮件。 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. 但是,如果要发送带粗体的格式化消息,则必须将消息格式化为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 . 不要忘记,制表符和换行符之类的空格实际上不会在HTML中做任何事情(除了在单词之间提供单个空格),因此,如果要在格式化消息中使用空格,则必须使用HTML标签,例如<br />marginpadding等CSS属性。

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 />
";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM