Answers.Body: <p>There are some examples of how to override the mailer component and transport settings in the official Craft docs here: <a href="https://docs.craftcms.com/v3/config/#mailer-component" rel="nofollow noreferrer">https://docs.craftcms.com/v3/config/#mailer-component</a></p>
  
  <p>For this particular sendmail example, you'd need to do something like this from <code>config/app.php</code>:</p>
  
  <pre><code>'components' =&gt; [
      'mailer' =&gt; function() {
          // Get the stored email settings
          $settings = Craft::$app-&gt;systemSettings-&gt;getEmailSettings();
  
          // Override the transport adapter class
          $settings-&gt;transportType = craft\mail\transportadapters\Sendmail::class;
  
          // Create a Mailer component config with these settings
          $config = craft\helpers\App::mailerConfig($settings);
          $config['transport']['command'] = '/usr/bin/sendmail -customflags';
  
          // Instantiate and return it
          return Craft::createObject($config);
      },
  ]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-01T18:24:55.053Z
Answers.LastActivityDate: 2018-11-01T18:24:55.053Z
Answers.UserDisplayName: Brad Bell
Body: <p>Many shared hosting accounts require custom flags that are passed to sendmail in order for them to work properly.</p>
  
  <p>Since Craft 3 uses <a href="https://github.com/swiftmailer/swiftmailer" rel="nofollow noreferrer">Swiftmailer</a> for its mailing library and Swiftmailer's default Sendmail command is <code>/usr/sbin/sendmail -bs</code> (<a href="https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Transport/SendmailTransport.php#L30" rel="nofollow noreferrer">https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Transport/SendmailTransport.php#L30</a>), is there a way to override that from Craft's <code>config/app.php</code> to set a custom sendmail command?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-01T21:00:03.610Z
Comments.Text: Are you aware that `-bs` makes sendmail talk SMTP over stdin&stdout?
Comments.UserDisplayName: AnFi onet.eu
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-02T22:10:46.667Z
Comments.Text: I had no idea @AnFi!
Comments.UserDisplayName: Brad Bell
Tags: <craft3><emails>
Title: Can you override the default sendmail path in Sendmail transport config in Craft 3?
ThreadText: # Can you override the default sendmail path in Sendmail transport config in Craft 3?
  
  (Asked by: username_0 on 2018-11-01)
  
  Many shared hosting accounts require custom flags that are passed to sendmail in order for them to work properly.
  
  Since Craft 3 uses [Swiftmailer](https://github.com/swiftmailer/swiftmailer) for its mailing library and Swiftmailer's default Sendmail command is `/usr/sbin/sendmail -bs` (<https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Transport/SendmailTransport.php#L30>), is there a way to override that from Craft's `config/app.php` to set a custom sendmail command?
  
  **Tags:** craft3, emails
  
  > **Comments:**
  > **username_1**: Are you aware that `-bs` makes sendmail talk SMTP over stdin&stdout?  
  > **username_0**: I had no idea @username_1!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-11-01. Score: 3
  
  There are some examples of how to override the mailer component and transport settings in the official Craft docs here: <https://docs.craftcms.com/v3/config/#mailer-component>
  
  For this particular sendmail example, you'd need to do something like this from `config/app.php`:
  
  ```
  'components' => [
      'mailer' => function() {
          // Get the stored email settings
          $settings = Craft::$app->systemSettings->getEmailSettings();
  
          // Override the transport adapter class
          $settings->transportType = craft\mail\transportadapters\Sendmail::class;
  
          // Create a Mailer component config with these settings
          $config = craft\helpers\App::mailerConfig($settings);
          $config['transport']['command'] = '/usr/bin/sendmail -customflags';
  
          // Instantiate and return it
          return Craft::createObject($config);
      },
  ]
  
  ```
  
  
  ---
  
  