WooCommerce emails add reply to header
A client was having issues with bounce back due to customers entering incorrect email addresses, so I updated the outbound email address used by WooCommerce to “[email protected]”, this meant any bounce backs would go to a null mailbox instead of to their mains “[email protected]” mailbox. However, this meant when customers hit reply, it would reply to the noreply@ mailbox. Using this code, I was able to set a Reply-To
header, so customers could still reply to emails.
Code
Drop this into your functions.php file and edit as required.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function woocommerceEmailAddReplyTo($headers = '', $id = '', $order) { $replyToName = get_bloginfo('name'); $replyToEmail = get_bloginfo('admin_email'); if (is_array($headers)) { $headers['Reply-to'] = $replyToName . ' < ' . $replyToEmail . '>'; } else { $headers .= 'Reply-to: ' . $replyToName . ' < ' . $replyToEmail . '>' . "\r\n"; } return $headers; } add_filter('woocommerce_email_headers', 'woocommerceEmailAddReplyTo', 10, 3); |
This code is provided as it and may require changes to work for your needs.