PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22.2
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmEmail.php

FrmEmail.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.22.2, at classes/models/FrmEmail.php

937 lines 20.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @since 2.03.04
8 */
9 class FrmEmail {
10
11 /**
12 * @var string
13 */
14 private $email_key = '';
15
16 /**
17 * @var array
18 */
19 private $to = array();
20
21 /**
22 * @var array
23 */
24 private $cc = array();
25
26 /**
27 * @var array
28 */
29 private $bcc = array();
30
31 /**
32 * @var string
33 */
34 private $from = '';
35
36 /**
37 * @var string
38 */
39 private $reply_to = '';
40
41 /**
42 * @var string
43 */
44 private $subject = '';
45
46 /**
47 * @var string
48 */
49 private $message = '';
50
51 /**
52 * @var array
53 */
54 private $attachments = array();
55
56 /**
57 * @var bool
58 */
59 private $is_plain_text = false;
60
61 /**
62 * @var bool
63 */
64 private $is_single_recipient = false;
65
66 /**
67 * @var bool
68 */
69 private $include_user_info = false;
70
71 /**
72 * @var string
73 */
74 private $charset = '';
75
76 /**
77 * @var string
78 */
79 private $content_type = 'text/html';
80
81 /**
82 * @var array
83 */
84 private $settings = array();
85
86 /**
87 * @var stdClass
88 */
89 private $entry;
90
91 /**
92 * @var stdClass
93 */
94 private $form;
95
96 /**
97 * @var int
98 */
99 private $action_id = 0;
100
101 /**
102 * FrmEmail constructor
103 *
104 * @param object $action
105 * @param object $entry
106 * @param object $form
107 */
108 public function __construct( $action, $entry, $form ) {
109 $this->set_email_key( $action );
110 $this->entry = $entry;
111 $this->form = $form;
112 $this->settings = $action->post_content;
113 $this->action_id = (int) $action->ID;
114
115 $user_id_args = self::get_user_id_args( $form->id );
116 $this->set_to( $user_id_args );
117 $this->set_cc( $user_id_args );
118 $this->set_bcc( $user_id_args );
119
120 if ( ! $this->has_recipients() ) {
121 return;
122 }
123
124 $this->set_from( $user_id_args );
125 $this->set_reply_to( $user_id_args );
126
127 $this->set_include_user_info();
128 $this->set_is_plain_text();
129 $this->set_is_single_recipient( $action );
130
131 $this->set_charset();
132 $this->set_content_type();
133
134 $this->set_subject();
135 $this->set_message();
136 $this->set_attachments();
137 }
138
139 /**
140 * Set the email key property
141 *
142 * @since 2.03.04
143 *
144 * @param object $action
145 *
146 * @return void
147 */
148 private function set_email_key( $action ) {
149 $this->email_key = $action->ID;
150 }
151
152 /**
153 * Set the to addresses
154 *
155 * @since 2.03.04
156 *
157 * @param array $user_id_args
158 *
159 * @return void
160 */
161 private function set_to( $user_id_args ) {
162 $to = $this->prepare_email_setting( $this->settings['email_to'], $user_id_args );
163 $to = $this->explode_emails( $to );
164
165 $where = array(
166 'it.field_id !' => 0,
167 'it.item_id' => $this->entry->id,
168 );
169 $values = FrmEntryMeta::getAll( $where, ' ORDER BY fi.field_order' );
170 $args = array(
171 'email_key' => $this->email_key,
172 'entry' => $this->entry,
173 'form' => $this->form,
174 );
175 $to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
176
177 $this->to = array_unique( (array) $to );
178
179 if ( empty( $this->to ) ) {
180 return;
181 }
182
183 $this->handle_phone_numbers();
184
185 $this->to = $this->format_recipients( $this->to );
186 }
187
188 /**
189 * Set the CC addresses
190 *
191 * @since 2.03.04
192 *
193 * @param array $user_id_args
194 *
195 * @return void
196 */
197 private function set_cc( $user_id_args ) {
198 $this->cc = $this->prepare_additional_recipients( $this->settings['cc'], $user_id_args );
199 }
200
201 /**
202 * Set the BCC addresses
203 *
204 * @since 2.03.04
205 *
206 * @param array $user_id_args
207 *
208 * @return void
209 */
210 private function set_bcc( $user_id_args ) {
211 $this->bcc = $this->prepare_additional_recipients( $this->settings['bcc'], $user_id_args );
212 }
213
214 /**
215 * Prepare CC and BCC recipients
216 *
217 * @since 2.03.04
218 *
219 * @param string $recipients
220 * @param array $user_id_args
221 *
222 * @return array
223 */
224 private function prepare_additional_recipients( $recipients, $user_id_args ) {
225 $recipients = $this->prepare_email_setting( $recipients, $user_id_args );
226 $recipients = $this->explode_emails( $recipients );
227
228 $recipients = array_unique( (array) $recipients );
229 $recipients = $this->format_recipients( $recipients );
230
231 return $recipients;
232 }
233
234 /**
235 * Set the From addresses
236 *
237 * @since 2.03.04
238 *
239 * @param array $user_id_args
240 * @return void
241 */
242 private function set_from( $user_id_args ) {
243 if ( empty( $this->settings['from'] ) ) {
244 $from = FrmEmailHelper::get_default_from_email();
245 } else {
246 $from = $this->prepare_email_setting( $this->settings['from'], $user_id_args );
247 }
248
249 $this->from = $this->format_from( $from );
250 }
251
252 /**
253 * Set the Reply To addresses
254 *
255 * @since 2.03.04
256 *
257 * @param array $user_id_args
258 *
259 * @return void
260 */
261 private function set_reply_to( $user_id_args ) {
262 $this->reply_to = trim( $this->settings['reply_to'] );
263
264 if ( $this->reply_to ) {
265 $this->reply_to = $this->prepare_email_setting( $this->settings['reply_to'], $user_id_args );
266 }
267
268 if ( ! $this->reply_to ) {
269 $this->reply_to = $this->get_email_from_name( $this->from );
270 }
271
272 $this->reply_to = $this->format_reply_to( $this->reply_to );
273 }
274
275 /**
276 * Set the is_plain_text property
277 * This should be set before the message
278 *
279 * @since 2.03.04
280 *
281 * @return void
282 */
283 private function set_is_plain_text() {
284 if ( $this->settings['plain_text'] ) {
285 $this->is_plain_text = true;
286 }
287 }
288
289 /**
290 * Set the include_user_info property
291 * This should be set before the message
292 *
293 * @since 2.03.04
294 *
295 * @return void
296 */
297 private function set_include_user_info() {
298 if ( isset( $this->settings['inc_user_info'] ) ) {
299 $this->include_user_info = $this->settings['inc_user_info'];
300 }
301 }
302
303 /**
304 * Set the is_single_recipient property
305 *
306 * @since 2.03.04
307 *
308 * @param object $action
309 *
310 * @return void
311 */
312 private function set_is_single_recipient( $action ) {
313 $args = array(
314 'form' => $this->form,
315 'entry' => $this->entry,
316 'action' => $action,
317 );
318
319 /**
320 * Send a separate email for email address in the "to" section
321 *
322 * @since 2.2.13
323 */
324 $this->is_single_recipient = apply_filters( 'frm_send_separate_emails', false, $args );
325 }
326
327 /**
328 * Set the charset
329 *
330 * @since 2.03.04
331 *
332 * @return void
333 */
334 private function set_charset() {
335 $this->charset = get_option( 'blog_charset' );
336 }
337
338 /**
339 * Set the content type
340 *
341 * @since 2.03.04
342 *
343 * @return void
344 */
345 private function set_content_type() {
346 if ( $this->is_plain_text ) {
347 $this->content_type = 'text/plain';
348 }
349 }
350
351 /**
352 * Set the subject
353 *
354 * @since 2.03.04
355 *
356 * @return void
357 */
358 private function set_subject() {
359 if ( empty( $this->settings['email_subject'] ) ) {
360 /* translators: %1$s: Form name, %2$s: Site name */
361 $this->subject = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $this->form->name, '[sitename]' );
362 } else {
363 $this->subject = $this->settings['email_subject'];
364 }
365
366 // This also replaces [sitename] shortcode in default.
367 $this->subject = FrmFieldsHelper::basic_replace_shortcodes( $this->subject, $this->form, $this->entry );
368
369 $args = array(
370 'form' => $this->form,
371 'entry' => $this->entry,
372 'email_key' => $this->email_key,
373 );
374 $this->subject = apply_filters( 'frm_email_subject', $this->subject, $args );
375 $this->subject = wp_specialchars_decode( strip_tags( stripslashes( $this->subject ) ), ENT_QUOTES );
376 }
377
378 /**
379 * Set the email message
380 *
381 * @since 2.03.04
382 *
383 * @return void
384 */
385 private function set_message() {
386 $this->message = $this->settings['email_message'];
387
388 if ( ! $this->is_plain_text ) {
389 // The decode is to support [default-html] shortcodes.
390 $this->message = html_entity_decode( $this->message );
391 }
392
393 $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry );
394 $prev_mail_body = $this->message;
395
396 // Make a copy to prevent changes by reference.
397 $pass_entry = clone $this->entry;
398 $mail_body = FrmEntriesHelper::replace_default_message(
399 $prev_mail_body,
400 array(
401 'id' => $this->entry->id,
402 'entry' => $pass_entry,
403 'plain_text' => $this->is_plain_text,
404 'user_info' => $this->include_user_info,
405 )
406 );
407
408 // Add the user info if it isn't already included
409 if ( $this->include_user_info && $prev_mail_body === $mail_body ) {
410 $data = $this->entry->description;
411 $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
412 $this->maybe_add_ip( $mail_body );
413 $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
414 $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
415 }
416
417 $this->message = $mail_body;
418
419 if ( $this->is_plain_text ) {
420 $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES );
421 $this->message = str_replace( '&nbsp;', '', $this->message );
422 } else {
423 $this->add_autop();
424 }
425
426 $this->message = apply_filters( 'frm_email_message', $this->message, $this->package_atts() );
427 }
428
429 /**
430 * Runs message through autop, extracting the content inside body tag if it has <body>.
431 *
432 * @return void
433 */
434 private function add_autop() {
435 $message = $this->message;
436 $result = preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
437 if ( ! empty( $match[1] ) ) {
438 $this->message = str_replace( $match[1], trim( wpautop( $match[1] ) ), $message );
439 } else {
440 $this->message = trim( wpautop( $message ) );
441 }
442 }
443
444 /**
445 * @param string $mail_body
446 *
447 * @return void
448 */
449 private function maybe_add_ip( &$mail_body ) {
450 if ( ! empty( $this->entry->ip ) ) {
451 $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $this->entry->ip . "\r\n";
452 }
453 }
454
455 /**
456 * Set the attachments for an email message
457 *
458 * @since 2.03.04
459 * @since 5.0.16 added new action_id key to $args.
460 *
461 * @return void
462 */
463 private function set_attachments() {
464 $args = array(
465 'entry' => $this->entry,
466 'email_key' => $this->email_key,
467 'settings' => $this->settings,
468 'action_id' => $this->action_id,
469 );
470
471 $this->attachments = apply_filters( 'frm_notification_attachment', array(), $this->form, $args );
472 }
473
474 /**
475 * Check if an email should send
476 *
477 * @since 2.03.04
478 *
479 * @return bool|mixed|void
480 */
481 public function should_send() {
482 if ( ! $this->has_recipients() ) {
483 $send = false;
484 } else {
485
486 $filter_args = array(
487 'message' => $this->message,
488 'subject' => $this->subject,
489 'recipient' => $this->to,
490 'header' => $this->package_header(),
491 );
492
493 /**
494 * Stop an email based on the message, subject, recipient,
495 * or any information included in the email header
496 *
497 * @since 2.2.8
498 */
499 $send = apply_filters( 'frm_send_email', true, $filter_args );
500 }
501
502 return $send;
503 }
504
505 /**
506 * Check if an email has any recipients
507 *
508 * @since 2.03.04
509 *
510 * @return bool
511 */
512 private function has_recipients() {
513 if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) {
514 return false;
515 }
516 return true;
517 }
518
519 /**
520 * Send an email
521 *
522 * @since 2.03.04
523 *
524 * @return bool
525 */
526 public function send() {
527 $this->remove_buddypress_filters();
528 $this->add_mandrill_filter();
529
530 $sent = false;
531 if ( count( $this->to ) > 1 && $this->is_single_recipient ) {
532 foreach ( $this->to as $recipient ) {
533 $sent = $this->send_single( $recipient );
534 }
535 } else {
536 $sent = $this->send_single( $this->to );
537 }
538
539 $this->remove_mandrill_filter();
540
541 return $sent;
542 }
543
544 /**
545 * Send a single email
546 *
547 * @since 2.03.04
548 *
549 * @param array|string $recipient
550 *
551 * @return bool
552 */
553 private function send_single( $recipient ) {
554 $header = apply_filters(
555 'frm_email_header',
556 $this->package_header(),
557 array(
558 'to_email' => $recipient,
559 'subject' => $this->subject,
560 )
561 );
562
563 $subject = $this->encode_subject( $this->subject );
564
565 $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
566
567 if ( ! $sent ) {
568 if ( is_array( $header ) ) {
569 $header = implode( "\r\n", $header );
570 }
571 $recipient = implode( ',', (array) $recipient );
572 $sent = mail( $recipient, $subject, $this->message, $header );
573 }
574
575 do_action( 'frm_notification', $recipient, $subject, $this->message );
576
577 return $sent;
578 }
579
580 /**
581 * Package the email header
582 *
583 * @since 2.03.04
584 *
585 * @return array
586 */
587 private function package_header() {
588 $header = array();
589
590 if ( ! empty( $this->cc ) ) {
591 $header[] = 'CC: ' . implode( ',', $this->cc );
592 }
593
594 if ( ! empty( $this->bcc ) ) {
595 $header[] = 'BCC: ' . implode( ',', $this->bcc );
596 }
597
598 $header[] = 'From: ' . $this->from;
599 $header[] = 'Reply-To: ' . $this->reply_to;
600 $header[] = 'Content-Type: ' . $this->content_type . '; charset="' . esc_attr( $this->charset ) . '"';
601
602 return $header;
603 }
604
605 /**
606 * Get the userID field ID and key for email settings
607 *
608 * @since 2.03.04
609 *
610 * @param int $form_id
611 *
612 * @return array
613 */
614 private function get_user_id_args( $form_id ) {
615 $user_id_args = array(
616 'field_id' => '',
617 'field_key' => '',
618 );
619
620 $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id );
621 if ( $user_id_args['field_id'] ) {
622 $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] );
623 }
624
625 return $user_id_args;
626 }
627
628 /**
629 * Prepare the to, cc, bcc, reply_to, and from setting
630 *
631 * @since 2.03.04
632 *
633 * @param string $value
634 * @param array $user_id_args
635 *
636 * @return string
637 */
638 private function prepare_email_setting( $value, $user_id_args ) {
639 if ( strpos( $value, '[' . $user_id_args['field_id'] . ']' ) !== false ) {
640 $value = str_replace( '[' . $user_id_args['field_id'] . ']', '[' . $user_id_args['field_id'] . ' show="user_email"]', $value );
641 } elseif ( strpos( $value, '[' . $user_id_args['field_key'] . ']' ) !== false ) {
642 $value = str_replace( '[' . $user_id_args['field_key'] . ']', '[' . $user_id_args['field_key'] . ' show="user_email"]', $value );
643 }
644
645 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
646
647 // Remove brackets and add a space in case there isn't one
648 $value = str_replace( '<', ' ', $value );
649 $value = str_replace( array( '"', '>' ), '', $value );
650
651 return $value;
652 }
653
654 /**
655 * Extract the emails from cc and bcc. Allow separation by , or ;.
656 * Trim the emails here as well
657 *
658 * @since 2.03.04
659 *
660 * @param string $emails
661 *
662 * @return array|string $emails
663 */
664 private function explode_emails( $emails ) {
665 $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
666 if ( is_array( $emails ) ) {
667 $emails = array_map( 'trim', $emails );
668 } else {
669 $emails = trim( $emails );
670 }
671
672 return $emails;
673 }
674
675 /**
676 * Format the recipients( to, cc, bcc)
677 *
678 * @param array $recipients
679 *
680 * @return array
681 */
682 private function format_recipients( $recipients ) {
683 if ( empty( $recipients ) ) {
684 return $recipients;
685 }
686
687 foreach ( $recipients as $key => $val ) {
688 $val = trim( $val );
689
690 if ( is_email( $val ) ) {
691 // If a plain email is used, no formatting is needed
692 continue;
693 }
694
695 $parts = explode( ' ', $val );
696 $email = end( $parts );
697
698 if ( is_email( $email ) ) {
699 // If user enters a name and email
700 $name = trim( str_replace( $email, '', $val ) );
701 } else {
702 // If user enters a name without an email
703 unset( $recipients[ $key ] );
704 continue;
705 }
706
707 $recipients[ $key ] = $this->format_from_email( $name, $email );
708 }//end foreach
709
710 return $recipients;
711 }
712
713 /**
714 * Format the From header
715 *
716 * @param string $from
717 *
718 * @return string
719 */
720 private function format_from( $from ) {
721 $from = trim( $from );
722
723 if ( is_email( $from ) ) {
724 // If a plain email is used, add the site name so "WordPress" doesn't get added
725 $from_name = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
726 $from_email = $from;
727 } else {
728 list( $from_name, $from_email ) = $this->get_name_and_email_for_sender( $from );
729 }
730
731 // if sending the email from a yahoo address, change it to the WordPress default
732 if ( strpos( $from_email, '@yahoo.com' ) ) {
733
734 // Get the site domain and get rid of www.
735 $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) );
736 if ( substr( $sitename, 0, 4 ) === 'www.' ) {
737 $sitename = substr( $sitename, 4 );
738 }
739
740 $from_email = 'wordpress@' . $sitename;
741 }
742
743 return $this->format_from_email( $from_name, $from_email );
744 }
745
746 /**
747 * Format the Reply To property
748 *
749 * @since 2.03.04
750 *
751 * @param string $reply_to
752 *
753 * @return string
754 */
755 private function format_reply_to( $reply_to ) {
756 $reply_to = trim( $reply_to );
757
758 if ( ! is_email( $reply_to ) ) {
759 list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to );
760 $reply_to = $this->format_from_email( $name, $email );
761 }
762
763 return $reply_to;
764 }
765
766 /**
767 * Get only the email if the name and email have been combined
768 *
769 * @since 3.0.06
770 *
771 * @param string $name
772 *
773 * @return string
774 */
775 private function get_email_from_name( $name ) {
776 $email = trim( trim( $name, '>' ), '<' );
777 if ( strpos( $email, '<' ) !== false ) {
778 $parts = explode( '<', $email );
779 $email = trim( $parts[1], '>' );
780 }
781
782 return $email;
783 }
784
785 /**
786 * Get the name and email for the From or Reply To header
787 *
788 * @since 2.03.04
789 *
790 * @param string $sender
791 *
792 * @return array
793 */
794 private function get_name_and_email_for_sender( $sender ) {
795 $parts = explode( ' ', $sender );
796 $end = end( $parts );
797
798 if ( is_email( $end ) ) {
799 $name = trim( str_replace( $end, '', $sender ) );
800 } else {
801 // Only a name was entered in the From or Reply To field
802 $name = $sender;
803 $end = get_option( 'admin_email' );
804 }
805
806 return array( $name, $end );
807 }
808
809 /**
810 * @since 3.0.06
811 *
812 * @param string $name
813 * @param string $email
814 */
815 private function format_from_email( $name, $email ) {
816 if ( '' !== $name ) {
817 $email = $name . ' <' . $email . '>';
818 }
819
820 return $email;
821 }
822
823 /**
824 * Remove phone numbers from To addresses
825 * Send the phone numbers to the frm_send_to_not_email hook
826 *
827 * @since 2.03.04
828 *
829 * @return void
830 */
831 private function handle_phone_numbers() {
832
833 foreach ( $this->to as $key => $recipient ) {
834 if ( '[admin_email]' !== $recipient && ! is_email( $recipient ) ) {
835 $recipient = explode( ' ', $recipient );
836
837 if ( is_email( end( $recipient ) ) ) {
838 continue;
839 }
840
841 do_action(
842 'frm_send_to_not_email',
843 array(
844 'e' => $recipient,
845 'subject' => $this->subject,
846 'mail_body' => $this->message,
847 'reply_to' => $this->reply_to,
848 'from' => $this->from,
849 'plain_text' => $this->is_plain_text,
850 'attachments' => $this->attachments,
851 'form' => $this->form,
852 'email_key' => $key,
853 )
854 );
855
856 // Remove phone number from to addresses
857 unset( $this->to[ $key ] );
858 }//end if
859 }//end foreach
860 }
861
862 /**
863 * Package an array of FrmEmail properties
864 *
865 * @since 2.03.04
866 *
867 * @return array
868 */
869 public function package_atts() {
870 return array(
871 'to_email' => $this->to,
872 'cc' => $this->cc,
873 'bcc' => $this->bcc,
874 'from' => $this->from,
875 'reply_to' => $this->reply_to,
876 'subject' => $this->subject,
877 'message' => $this->message,
878 'attachments' => $this->attachments,
879 'plain_text' => $this->is_plain_text,
880 'form' => $this->form,
881 'entry' => $this->entry,
882 );
883 }
884
885 /**
886 * Remove the Buddypress email filters
887 *
888 * @since 2.03.04
889 *
890 * @return void
891 */
892 private function remove_buddypress_filters() {
893 remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
894 remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
895 }
896
897 /**
898 * Add Mandrill line break filter
899 * Remove line breaks in HTML emails to prevent conflicts with Mandrill
900 *
901 * @since 2.03.04
902 *
903 * @return void
904 */
905 private function add_mandrill_filter() {
906 if ( ! $this->is_plain_text ) {
907 add_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
908 }
909 }
910
911 /**
912 * Remove Mandrill line break filter
913 *
914 * @since 2.03.04
915 *
916 * @return void
917 */
918 private function remove_mandrill_filter() {
919 remove_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
920 }
921
922 /**
923 * Encode the email subject
924 *
925 * @param string $subject
926 *
927 * @return string
928 */
929 private function encode_subject( $subject ) {
930 if ( apply_filters( 'frm_encode_subject', false, $subject ) ) {
931 $subject = '=?' . $this->charset . '?B?' . base64_encode( $subject ) . '?=';
932 }
933
934 return $subject;
935 }
936 }
937