0

I was 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?

2 Answers 2

2

You can add newlines, tabs, and spaces, by simply including newlines, tabs, and spaces in your message.

mail('[email protected]', '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('[email protected]', '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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

With single quotes, \t and \n will not be treated as escaped characters. Strings with escape sequences need to be in double quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.