Verified Commit 9a04a208 authored by Dave Long's avatar Dave Long
Browse files

task: #3579153 Remove fallback to sendmail_from ini setting when sending mails

By: znerol
By: scontzen
By: sivaji_ganesh_jojodae
By: longwave
By: mehak22
By: poker10
parent 3b0329cc
Loading
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -127,13 +127,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#weight' => -20,
      '#access' => empty($install_state['config_install_path']),
    ];
    // Use the default site mail if one is already configured, or fall back to
    // PHP's configured sendmail_from.
    $default_site_mail = $this->config('system.site')->get('mail') ?: ini_get('sendmail_from');
    $form['site_information']['site_mail'] = [
      '#type' => 'email',
      '#title' => $this->t('Site email address'),
      '#default_value' => $default_site_mail,
      '#default_value' => $this->config('system.site')->get('mail'),
      '#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."),
      '#required' => TRUE,
      '#weight' => -15,
+0 −3
Original line number Diff line number Diff line
@@ -229,9 +229,6 @@ public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL,
  public function doMail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
    $site_config = $this->configFactory->get('system.site');
    $site_mail = $site_config->get('mail');
    if (empty($site_mail)) {
      $site_mail = ini_get('sendmail_from');
    }

    // Bundle up the variables into a structured array for altering.
    $message = [
+1 −6
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\ConfigTarget;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\RedundantEditableConfigNamesTrait;
use Drupal\Core\Path\PathValidatorInterface;
@@ -96,11 +95,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    $form['site_information']['site_mail'] = [
      '#type' => 'email',
      '#title' => $this->t('Email address'),
      '#config_target' => new ConfigTarget(
        'system.site',
        'mail',
        fromConfig: fn($value) => $value ?: ini_get('sendmail_from'),
      ),
      '#config_target' => 'system.site:mail',
      '#description' => $this->t("The <em>From</em> address in automated emails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this email being flagged as spam.)"),
      '#required' => TRUE,
    ];
+0 −3
Original line number Diff line number Diff line
@@ -533,9 +533,6 @@ function _user_mail_notify($op, AccountInterface $account) {
    if (empty($site_mail)) {
      $site_mail = \Drupal::config('system.site')->get('mail');
    }
    if (empty($site_mail)) {
      $site_mail = ini_get('sendmail_from');
    }
    if ($account->getEmail()) {
      $mail = \Drupal::service('plugin.manager.mail')->mail('user', $op, $account->getEmail(), $account->getPreferredLangcode(), $params, $site_mail);
    }