PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.3.7
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.3.7
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.3.7, at includes/class-emailer.php

68 lines 1.6 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 null|WeForms_Mailer_Contract
12 */
13 private $gateway = null;
14
15 function __construct() {
16
17 require_once WEFORMS_INCLUDES . '/email/gateways/interface-mailer.php';
18
19 $this->gateway = $this->get_sending_gateway();
20 }
21
22 /**
23 * Get available gateways
24 *
25 * @return array
26 */
27 public function get_available_gateways() {
28 require_once WEFORMS_INCLUDES . '/email/gateways/class-emailer-wpmail.php';
29
30 $gateways = apply_filters( 'weforms_email_gateways', array(
31 'wordpress' => new WeForms_Emailer_WPMail()
32 ) );
33
34 return $gateways;
35 }
36
37 /**
38 * Get the sending gateway class
39 *
40 * @return WeForms_Mailer_Contract
41 */
42 public function get_sending_gateway() {
43 $gateway = weforms_get_settings( 'email_gateway', 'WordPress' );
44 $available_gateways = $this->get_available_gateways();
45
46 if ( array_key_exists( $gateway, $available_gateways ) ) {
47 return $available_gateways[ $gateway ];
48 }
49
50 return $available_gateways['wordpress'];
51 }
52
53 /**
54 * Send email via the gateway
55 *
56 * @param string $to Email addresses to send message
57 * @param string $subject Email subject
58 * @param string $body Message contents
59 * @param string $headers Optional. Files to attach.
60 *
61 * @return bool
62 */
63 public function send( $to, $subject, $body, $headers ) {
64 return $this->gateway->send( $to, $subject, $body, $headers );
65 }
66
67 }
68