phpmailerHow can I use PHPMailer to create an HTML body for my emails?
Using PHPMailer to create an HTML body for emails is quite simple. The example code below shows how to set the body of an email to HTML using PHPMailer:
$mail = new PHPMailer;
$mail->isHTML(true);
$mail->Body = '<h1>Hello World!</h1><p>This is an HTML email.</p>';
The code above creates a new PHPMailer instance, sets the isHTML property to true, and sets the Body property to an HTML string.
The parts of the code above are:
$mail = new PHPMailer;- creates a new PHPMailer instance.$mail->isHTML(true);- sets theisHTMLproperty to true, indicating that the body of the email should be treated as HTML.$mail->Body = '<h1>Hello World!</h1><p>This is an HTML email.</p>';- sets theBodyproperty to an HTML string.
For more information on using PHPMailer to create HTML emails, see the PHPMailer documentation.
More of Phpmailer
- How do I use PHPMailer to attach a ZIP file?
- How do I configure PHPmailer to use Zoho SMTP?
- How can I use PHPMailer to send emails through Outlook?
- How can I use PHPMailer with XAMPP on a localhost?
- How can I send a UTF-8 encoded email using PHPMailer?
- How can I set a timeout for PHPMailer SMTP?
- How can I set up PHPMailer to use Zimbra SMTP?
- How do I use PHPMailer to encode emails in UTF-8?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer to send emails through Yandex?
See more codes...