phpmailerHow do I set the X-Mailer header using PHPMailer?
The X-Mailer header can be set using PHPMailer by using the addCustomHeader()
method. The following example code block sets the X-Mailer header to MyXMailer
:
<?php
// Include PHPMailer library
require_once('PHPMailer/PHPMailerAutoload.php');
// Create new PHPMailer instance
$mail = new PHPMailer;
// Set X-Mailer header
$mail->addCustomHeader('X-Mailer', 'MyXMailer');
// ...
?>
The addCustomHeader()
method takes two parameters: the header name and header value. The header name is the name of the header, in this case X-Mailer
, and the header value is the value of the header, in this case MyXMailer
.
The following list explains the parts of the code example:
require_once('PHPMailer/PHPMailerAutoload.php');
: This line includes the PHPMailer library.$mail = new PHPMailer;
: This line creates a new PHPMailer instance.$mail->addCustomHeader('X-Mailer', 'MyXMailer');
: This line sets the X-Mailer header toMyXMailer
.
Helpful links
More of Phpmailer
- How can I use PHPMailer without SMTP secure?
- How can I use PHPMailer in Yii 1?
- How do I determine which version of PHPMailer I'm using?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer to send emails with a Yahoo account?
- How can I use PHPMailer to send emails through Yandex?
- How do I use PHPMailer to send a file?
- How do I use PHPMailer with OAuth 2.0?
- How do I use PHPMailer to attach a ZIP file?
- How do I use PHPMailer with Yii2?
See more codes...