Setting a Custom Reply-To Email

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy but don’t provide support for code customizations or 3rd party development.

For a simple approach to adding custom code to your site, please see WPBeginner’s guide to using WPCode.


Would you like to change the reply-to email address for all emails sent from your WordPress site? The reply-to email address can differ across each plugin or integration used to send emails from your site, depending on how you have each one configured.

In this tutorial, we’ll show you how to use a PHP snippet to ensure all emails sent from your site have the same reply-to email address.

Note: Be sure to install and activate the WP Mail SMTP plugin on your site before adding the code snippet provided in this tutorial.


Simply copy and paste this snippet to your site. On line 3, you’ll need to replace Pattie Paloma and [email protected] with your desired reply-to name and email address.

function wp_mail_smtp_dev_reply_to( $args ) {

 $reply_to = 'Reply-To: Pattie Paloma <[email protected]>';

 if ( ! empty( $args['headers'] ) ) {
  if ( ! is_array( $args['headers'] ) ) {
   $args['headers'] = array_filter( explode( "\n", str_replace( "\r\n", "\n", $args['headers'] ) ) );

  // Filter out all other Reply-To headers.
  $args['headers'] = array_filter( $args['headers'], function ( $header ) {
   return strpos( strtolower( $header ), 'reply-to' ) !== 0;
  } );
 } else {
  $args['headers'] = [];

 $args['headers'][] = $reply_to;

 return $args;

add_filter( 'wp_mail', 'wp_mail_smtp_dev_reply_to', PHP_INT_MAX );

Note: The reply-to email address you use in this code snippet will overwrite all other reply-to addresses set by WordPress or 3rd party plugins.

That’s it! Now you know how to successfully change the reply-to email for all the emails sent from your WordPress site.

Next, want to explore more ways to customize your WP Mail SMTP setup? Be sure to take a look at our other code snippets for more customization options.