@@ -255,10 +255,12 @@ protected function get_request_headers($hide_api_key = false)
255255 }
256256
257257 /**
258- * Returns the list of Reply-To headers
258+ * Returns the list of Reply-To recipients
259+ * For WordPress version below 4.6
259260 * @return array
261+ * TODO Remove this when wordpress does not support version below 4.6
260262 */
261- protected function get_reply_to ()
263+ protected function parse_reply_to_from_custom_header ()
262264 {
263265 $ replyTos = array ();
264266 foreach ($ this ->CustomHeader as $ header ) { // wp_mail sets Reply-To as custom header (does not use phpmailer->addReplyTo)
@@ -271,6 +273,37 @@ protected function get_reply_to()
271273 return implode (', ' , $ replyTos );
272274 }
273275
276+ /**
277+ * Returns list of Reply-To recipients
278+ * For WordPress 4.6 and above
279+ * @return array Formatted list of reply tos
280+ */
281+ protected function parse_reply_to ()
282+ {
283+ $ replyTos = array ();
284+ foreach ($ this ->ReplyTo as $ reply_to ) {
285+ $ name = $ reply_to [1 ];
286+ $ email = $ reply_to [0 ];
287+ if (empty ($ name )) {
288+ $ replyTos [] = $ email ;
289+ } else {
290+ $ replyTos [] = sprintf ('%s <%s> ' , $ name , $ email );
291+ }
292+ }
293+
294+ return implode (', ' , $ replyTos );
295+ }
296+
297+ protected function get_reply_to ()
298+ {
299+ $ wp_version = get_bloginfo ('version ' );
300+ if (version_compare ($ wp_version , '4.6 ' ) == -1 ) { // if lower than 4.6
301+ return $ this ->parse_reply_to_from_custom_header ();
302+ } else {
303+ return $ this ->parse_reply_to ();
304+ }
305+ }
306+
274307 protected function build_recipient ($ email , $ name = '' , $ header_to = '' ) {
275308 $ recipient = array (
276309 'address ' => array (
0 commit comments