PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.21.1
GiveWP – Donation Plugin and Fundraising Platform v3.21.1
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / FormBuilder / EmailPreview / Controllers / SendEmailPreview.php
SendEmailPreview.php
38 lines 884 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\FormBuilder\EmailPreview\Controllers;
4
5 use Give\FormBuilder\EmailPreview\Actions\BuildEmailPreview;
6 use WP_REST_Request;
7 use WP_REST_Response;
8
9 /**
10 * Send email preview.
11 *
12 * @since 3.0.0
13 */
14 class SendEmailPreview
15 {
16 /**
17 * @since 3.0.0
18 *
19 * @param WP_REST_Request $request
20 *
21 * @return WP_REST_Response
22 */
23 public function __invoke(WP_REST_Request $request): WP_REST_Response
24 {
25 $email = $request->get_param('email_address');
26 $subject = $request->get_param('email_subject');
27 $message = give(BuildEmailPreview::class)->__invoke($request);
28 $headers = 'From:' . $email . "\r\n" .
29 'Content-Type: text/html; charset=UTF-8' . "\r\n";
30
31 $sent = wp_mail($email, $subject, $message, $headers);
32
33 ob_clean();
34
35 return new WP_REST_Response($sent, 200);
36 }
37 }
38