# bit-form/3.3.1/includes/Core/Util/MailConfig.php

Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator &amp; Custom Form Builder, version 3.3.1. 61 lines.

- Page: https://pluginprobe.com/plugins/bit-form/3.3.1/code/includes/Core/Util/MailConfig.php
- Raw: https://pluginprobe.com/plugins/bit-form/3.3.1/raw/includes/Core/Util/MailConfig.php
- Modified: 2026-07-21T12:01:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bit-form/3.3.1/code/includes/Core/Util/MailConfig.php#L10-L20`.

```php
<?php

namespace BitCode\BitForm\Core\Util;

if (!defined('ABSPATH')) {
  exit;
}

use BitCode\BitForm\Core\Integration\IntegrationHandler;

/**
 * Class handling plugin activation.
 *
 * @since 1.0.0
 */
final class MailConfig
{
  private $config;

  public function sendMail($config = [])
  {
    $this->config = $config;
    add_action('phpmailer_init', [$this, 'mailConfig'], 10, 1);
  }

  public function mailConfig($phpmailer)
  {
    $integrationHandler = new IntegrationHandler(0);
    $formIntegrations = $integrationHandler->getAllIntegration('mail', 'smtp', 1);
    if (!isset($formIntegrations->errors['result_empty'])) {
      $integrationRow = Utilities::firstRow($formIntegrations);
      if ($integrationRow && 1 === (int) $integrationRow->status) {
        $integration_details = Utilities::jsonObj($integrationRow->integration_details ?? '');
        $phpmailer->Mailer = 'smtp';
        $phpmailer->Host = $integration_details->smtp_host ?? '';
        $phpmailer->SMTPAuth = true;
        if (!empty($integration_details->re_email_address)) {
          $phpmailer->addReplyTo($integration_details->re_email_address, 'reply-to');
        }
        $phpmailer->Port = $integration_details->port ?? '';
        $phpmailer->Username = $integration_details->smtp_user_name ?? '';
        $phpmailer->Password = $integration_details->smtp_password ?? '';
        $phpmailer->SMTPSecure = $integration_details->encryption ?? '';
        // $phpmailer->SMTPDebug = 1;
        // $phpmailer->Debugoutput = 'error_log';
        $phpmailer->From = $integration_details->form_email_address ?? '';
        $phpmailer->Sender = $integration_details->form_email_address ?? '';
        if (isset($this->config['from_email']) && !empty($this->config['from_email'])) {
          $phpmailer->From = $this->config['from_email'];
          $phpmailer->Sender = $this->config['from_email'];
        }
        $from_name = $integration_details->form_name ?? '';
        if (isset($this->config['from_name']) && !empty($this->config['from_name'])) {
          $from_name = $this->config['from_name'];
        }
        $phpmailer->FromName = $from_name;
      }
    }
  }
}

```
