Add option to customize the "sent from" and "reply to" addresses on emails sent by the SendEmail step #1354
andergmartins
started this conversation in
Feature Requests
Replies: 1 comment
-
Here is the custom code I sent to the customer, until we implement this new feature. Please, not this only works for Future 4.7+. <?php
/**
* Plugin Name: Custom Email
* Plugin URI: https://example.com/plugins/custom-email
* Description: A custom plugin for handling email functionality
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: custom-email
* Domain Path: /languages
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
add_action('publishpressfuture_workflow_engine_execute_step', function ($step) {
if ($step['node']['data']['name'] !== 'action/core.send-email') {
return;
}
add_filter('wp_mail', 'mycustom_change_reply_to_address');
add_filter('wp_mail_from_name', 'mycustom_change_from_name');
add_filter('wp_mail_from', 'mycustom_change_from_address');
});
function mycustom_change_reply_to_address($args) {
// Remove any existing Reply-To header
$args['headers'] = preg_replace('/Reply-To:.*?\n/i', '', $args['headers']);
// Add the new Reply-To header
$args['headers'] = $args['headers'] . "\nReply-To: custom-reply-to@test.com";
return $args;
}
function mycustom_change_from_name($name) {
return 'Custom From Name';
}
function mycustom_change_from_address($address) {
return 'custom-from@test.com';
}
/**
* Remove the filter when all the workflows finished running.
*/
add_action('publishpressfuture_workflow_engine_workflows_initialized', function () {
remove_filter('wp_mail', 'mycustom_change_reply_to_address');
remove_filter('wp_mail_from_name', 'mycustom_change_from_name');
remove_filter('wp_mail_from', 'mycustom_change_from_address');
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Some users want to use different "sent from - name and email" and "reply to" addresses on emails sent by workflows. We could have a new panel with specific settings in the SendEmail step to configure that.
Beta Was this translation helpful? Give feedback.
All reactions