@@ -255,10 +255,12 @@ protected function get_request_headers($hide_api_key = false)
255
255
}
256
256
257
257
/**
258
- * Returns the list of Reply-To headers
258
+ * Returns the list of Reply-To recipients
259
+ * For WordPress version below 4.6
259
260
* @return array
261
+ * TODO Remove this when wordpress does not support version below 4.6
260
262
*/
261
- protected function get_reply_to ()
263
+ protected function parse_reply_to_from_custom_header ()
262
264
{
263
265
$ replyTos = array ();
264
266
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()
271
273
return implode (', ' , $ replyTos );
272
274
}
273
275
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
+
274
307
protected function build_recipient ($ email , $ name = '' , $ header_to = '' ) {
275
308
$ recipient = array (
276
309
'address ' => array (
0 commit comments