php - How to add Reply-To header in $woocommerce->mailer() -


i had custom woocommerce mailer function below sending emails customers notification of there purchase, got requirement add reply-to tag.

to describe in detail, customer has email($order->billing_email) order notification store@mycompany.com , need append reply-to tag support@mycompany.com.

what emails send store@mycompany.com, when customers hit reply when want ask questions, these replies go support@mycompany.com

can 1 me how change $mailer->send function achieve requirement ?

function my_awesome_publication_notification($order_id, $checkout=null) {    global $woocommerce;    $order = new wc_order( $order_id );    if($order->status === 'completed' ) {       // create mailer       $mailer = $woocommerce->mailer();        $message_body = __( 'hello world!!!' );        $message = $mailer->wrap_message(         // message head , message body.         sprintf( __( 'order %s received' ), $order->get_order_number() ), $message_body );         // client email, email subject , message.      $mailer->send( $order->billing_email, sprintf( __( 'order %s received' ), $order->get_order_number() ), $message );      }     } } 

when looking @ class wc_email @ send() function have:

send( string $to, string $subject, string $message, string $headers, string $attachments )  

transposing code, $headers used way:

function my_awesome_publication_notification($order_id, $checkout=null) {     global $woocommerce;      // order object.     $order = new wc_order( $order_id );      if($order->status === 'completed' ) {          // create mailer         $mailer = $woocommerce->mailer();          $message_body = __( 'hello world!!!' );          // message head , message body.         $message = $mailer->wrap_message( sprintf( __( 'order %s received' ), $order->get_order_number() ), $message_body );          // here header         $reply_to_email = 'support@mycompany.com';         $headers = array( sprintf( 'reply-to: %s', $reply_to_email ) );         // or instead, try in case:         // $headers = 'reply-to: ' . $reply_to_email . '\r\n';          // client email, email subject , message (+ header "reply to").         $mailer->send( $order->billing_email, sprintf( __( 'order %s received' ), $order->get_order_number() ), $message, $headers );     } } 

this should work. please take last reference code, it's similar yours…

references:


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -