I have already implemented that by searching a signature phrase. It could be useful for someone else. Here is example of “Order processing” email.
I add a signature to email template:
function add_pot_sendgrid_order_mark($order, $sent_to_admin = false, $plain_text = false, $email = '') {
if (!$sent_to_admin && !$plain_text) {
echo '<span style="display:none" data-pot-sendgrid="order-confirmation-email321"></span>';
}
}
add_action( 'woocommerce_email_before_order_table', 'add_pot_sendgrid_order_mark', 10, 4);
And then catch this email by signature
function set_email_template($args) {
// True if signature has been founded
$isOrder = strpos($args['message'], 'order-confirmation-email321');
...
return $args;
}
add_filter('wp_mail', 'set_email_template', 100);
Thanks @bcworkz for conversation!