phpmailerHow do I add a new line character in a PHPMailer message?
Adding a new line character in PHPMailer message is quite simple. You can use the following example code block to do it:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->Body = "This is the first line\nThis is the second line";
echo $mail->Body;
The output of the above code will be:
This is the first line
This is the second line
Code explanation
require 'PHPMailerAutoload.php'
: This includes the PHPMailer library.$mail = new PHPMailer
: This creates a new PHPMailer instance.$mail->Body = "This is the first line\nThis is the second line"
: This sets the body of the message and adds a new line character (\n) between the two lines.echo $mail->Body
: This outputs the body of the message.
Helpful links
More of Phpmailer
- How do I use PHPMailer to attach a ZIP file?
- How do I configure the timeout settings for PHPMailer?
- How can I use PHPMailer without SMTP secure?
- How can I configure PHPMailer to support Polish characters?
- How can I configure PHPMailer to work with GoDaddy?
- How do I determine which version of PHPMailer I'm using?
- How can I configure PHPMailer to ignore TLS certificate errors?
- How can I use PHPMailer in Yii 1?
- How can I use PHPMailer to send emails with a Yahoo account?
- How can I use PHPMailer with Laravel?
See more codes...