PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.25
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.25
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / class-emailer.php

class-emailer.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.6.25, at includes/class-emailer.php

66 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Emailer Class
5 */
6 class WeForms_Emailer {
7
8 /**
9 * The default gateway to send
10 *
11 * @var WeForms_Mailer_Contract|null
12 */
13 private $gateway = null;
14
15 public function __construct() {
16 require_once WEFORMS_INCLUDES . '/email/gateways/interface-mailer.php';
17
18 $this->gateway = $this->get_sending_gateway();
19 }
20
21 /**
22 * Get available gateways
23 *
24 * @return array
25 */
26 public function get_available_gateways() {
27 require_once WEFORMS_INCLUDES . '/email/gateways/class-emailer-wpmail.php';
28
29 $gateways = apply_filters( 'weforms_email_gateways', [
30 'wordpress' => new WeForms_Emailer_WPMail(),
31 ] );
32
33 return $gateways;
34 }
35
36 /**
37 * Get the sending gateway class
38 *
39 * @return WeForms_Mailer_Contract
40 */
41 public function get_sending_gateway() {
42 $gateway = weforms_get_settings( 'email_gateway', 'WordPress' );
43 $available_gateways = $this->get_available_gateways();
44
45 if ( array_key_exists( $gateway, $available_gateways ) ) {
46 return $available_gateways[ $gateway ];
47 }
48
49 return $available_gateways['wordpress'];
50 }
51
52 /**
53 * Send email via the gateway
54 *
55 * @param string $to Email addresses to send message
56 * @param string $subject Email subject
57 * @param string $body Message contents
58 * @param string $headers Optional. Files to attach.
59 *
60 * @return bool
61 */
62 public function send( $to, $subject, $body, $headers ) {
63 return $this->gateway->send( $to, $subject, $body, $headers );
64 }
65 }
66