PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.2
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Util / MailConfig.php

MailConfig.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.1.2, at includes/Core/Util/MailConfig.php

60 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Util;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 use BitCode\BitForm\Core\Integration\IntegrationHandler;
10
11 /**
12 * Class handling plugin activation.
13 *
14 * @since 1.0.0
15 */
16 final class MailConfig
17 {
18 private $config;
19
20 public function sendMail($config = [])
21 {
22 $this->config = $config;
23 add_action('phpmailer_init', [$this, 'mailConfig'], 10, 1);
24 }
25
26 public function mailConfig($phpmailer)
27 {
28 $integrationHandler = new IntegrationHandler(0);
29 $formIntegrations = $integrationHandler->getAllIntegration('mail', 'smtp', 1);
30 if (!isset($formIntegrations->errors['result_empty'])) {
31 if (1 === (int) $formIntegrations[0]->status) {
32 $integration_details = json_decode($formIntegrations[0]->integration_details);
33 $phpmailer->Mailer = 'smtp';
34 $phpmailer->Host = $integration_details->smtp_host;
35 $phpmailer->SMTPAuth = true;
36 if (!empty($integration_details->re_email_address)) {
37 $phpmailer->addReplyTo($integration_details->re_email_address, 'reply-to');
38 }
39 $phpmailer->Port = $integration_details->port;
40 $phpmailer->Username = $integration_details->smtp_user_name;
41 $phpmailer->Password = $integration_details->smtp_password;
42 $phpmailer->SMTPSecure = $integration_details->encryption;
43 // $phpmailer->SMTPDebug = 1;
44 // $phpmailer->Debugoutput = 'error_log';
45 $phpmailer->From = $integration_details->form_email_address;
46 $phpmailer->Sender = $integration_details->form_email_address;
47 if (isset($this->config['from_email']) && !empty($this->config['from_email'])) {
48 $phpmailer->From = $this->config['from_email'];
49 $phpmailer->Sender = $this->config['from_email'];
50 }
51 $from_name = $integration_details->form_name;
52 if (isset($this->config['from_name']) && !empty($this->config['from_name'])) {
53 $from_name = $this->config['from_name'];
54 }
55 $phpmailer->FromName = $from_name;
56 }
57 }
58 }
59 }
60