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 configure PHPMailer to support Polish characters?
- How do I use PHPMailer to reply to an email?
- How can I configure PHPMailer to work with GoDaddy?
- How can I use PHPMailer without SMTP secure?
- How do I check which version of PHPMailer I'm using?
- How do I determine which version of PHPMailer I'm using?
- How do I get the message ID of a sent email using PHPMailer?
- How do I use PHPMailer with Yii2?
- How do I manually install PHPMailer?
- How can I use PHPMailer to send emails with a Yahoo account?
See more codes...