| @@ -8,14 +8,20 @@ | ||
| 8 | 8 | * Class handling plugin activation. |
| 9 | 9 | * |
| 10 | 10 | * @since 1.0.0 |
| 11 | 11 | */ |
| 12 | -final class MailConfig { | |
| 13 | - public function sendMail() { | |
| 12 | +final class MailConfig | |
| 13 | +{ | |
| 14 | + private $config; | |
| 15 | + | |
| 16 | + public function sendMail($config = []) | |
| 17 | + { | |
| 18 | + $this->config = $config; | |
| 14 | 19 | add_action('phpmailer_init', [$this, 'mailConfig'], 10, 1); |
| 15 | 20 | } |
| 16 | 21 | |
| 17 | - public function mailConfig($phpmailer) { | |
| 22 | + public function mailConfig($phpmailer) | |
| 23 | + { | |
| 18 | 24 | $integrationHandler = new IntegrationHandler(0); |
| 19 | 25 | $formIntegrations = $integrationHandler->getAllIntegration('mail', 'smtp', 1); |
| 20 | 26 | if (!isset($formIntegrations->errors['result_empty'])) { |
| 21 | 27 | if (1 === (int) $formIntegrations[0]->status) { |
| @@ -29,11 +35,15 @@ | ||
| 29 | 35 | $phpmailer->Port = $integration_details->port; |
| 30 | 36 | $phpmailer->Username = $integration_details->smtp_user_name; |
| 31 | 37 | $phpmailer->Password = $integration_details->smtp_password; |
| 32 | 38 | $phpmailer->SMTPSecure = $integration_details->encryption; |
| 33 | - $phpmailer->SMTP_DEBUG = 1; | |
| 39 | + // $phpmailer->SMTP_DEBUG = 1; | |
| 34 | 40 | $phpmailer->From = $integration_details->form_email_address; |
| 35 | - $phpmailer->FromName = $integration_details->form_name; | |
| 41 | + $from_name = $integration_details->form_name; | |
| 42 | + if (isset($this->config['from_name']) && !empty($this->config['from_name'])) { | |
| 43 | + $from_name = $this->config['from_name']; | |
| 44 | + } | |
| 45 | + $phpmailer->FromName = $from_name; | |
| 36 | 46 | } |
| 37 | 47 | } |
| 38 | 48 | } |
| 39 | 49 | } |