phpmailerHow can I add a new line to the body of an email using PHPMailer?
Adding a new line to the body of an email using PHPMailer is a simple process. The following example code shows how to add a new line with a text message to the body of an email using PHPMailer:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->Body = "Hello!\nThis is a new line.";
echo $mail->Body;
?>
The output of this code will be:
Hello!
This is a new line.
The code consists of the following parts:
- The
require
statement which includes the PHPMailerAutoload.php file. This file contains the necessary code for PHPMailer to work correctly. - The
$mail
variable which is an instance of thePHPMailer
class. - The
$mail->Body
statement which sets the body of the email. - The
echo
statement which prints out the body of the email.
For more information on how to use PHPMailer to send emails, see the PHPMailer documentation.
More of Phpmailer
- How can I configure PHPMailer to support Polish characters?
- How do I use PHPMailer to send a file?
- How do I configure PHPMailer to use TLS 1.2?
- How can I use PHPMailer to send emails with a BCC address?
- How can I use PHPMailer in Yii 1?
- How do I determine which version of PHPMailer I'm using?
- How can I use PHPMailer without SMTP secure?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer to send emails with a Yahoo account?
See more codes...