What are some common methods for formatting text in PHP for email generation?
When generating emails in PHP, it is common to format text using HTML markup to create visually appealing and structured content. Some common methods for formatting text in PHP for email generation include using HTML tags such as <p> for paragraphs, <strong> for bold text, <em> for italic text, <ul> and <li> for unordered lists, and <a> for hyperlinks.
$message = "
<html>
<head>
<title>Email Content</title>
</head>
<body>
<p>This is a paragraph of text.</p>
<p><strong>This is bold text.</strong></p>
<p><em>This is italic text.</em></p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<p>Visit our website <a href='http://www.example.com'>here</a>.</p>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($to, $subject, $message, $headers);
Keywords
Related Questions
- How can PHP developers ensure that their code is secure and free from SQL injection vulnerabilities when sorting database entries?
- How can using mysqli or PDO improve the security of a PHP application?
- What are the best practices for displaying MySQL data in a visually appealing table format using PHP?