# Remove the X-Mailer Header From Emails

> Stops outgoing emails announcing "PHPMailer" and its version in the X-Mailer header, which reveals details about your server and can count against you in spam filters.

- Type: PHP
- Runs: Run everywhere
- Category: [Email](https://wpide.com/library/category/email/)
- Tags: email, headers, security
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/email-remove-x-mailer/

## Code

```php
add_action( 'phpmailer_init', function ( $phpmailer ) {
    $phpmailer->XMailer = ' ';
} );
```

## Notes

PHPMailer omits the header entirely when it is set to a single space.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove the X-Mailer Header From Emails" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
