Any ideas how I can modify this PHP to edit the outbound email subject line?

[ad_1]

So, I use a booking plugin for my site (by WPDEVART). It allows me to edit the email header and subject line. However, because my SMTP host would not allow changing of the the sender email I have had to use the below code to edit the reply-to address instead:

function wp_mail_smtp_dev_reply_to( $args ) {

*//[useremail] is a shortcode provided by my booking plugin
$reply_to = ‘Reply-To:TEST USER <[useremail]>’;

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 );

Now, this works great. It means that I can 1-click reply in my email to reply to customer booking requests.

However, there is a problem in that email clients will assume that all of the emails are part of the same thread (because sender and subject are always the same).

This means I have a huge, long thread instead of receiving a ‘separate email’ for each booking request. I’m not proficient in PHP and would hugely appreciate if anyone could modify this code to also edit the subject line.

Thanks for any help!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer