Skip to content

Instantly share code, notes, and snippets.

@piotrpog
Last active March 9, 2019 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrpog/a57e19eaeb8ee0130073acaded0919a5 to your computer and use it in GitHub Desktop.
Save piotrpog/a57e19eaeb8ee0130073acaded0919a5 to your computer and use it in GitHub Desktop.
Config for connecting to SMTP server with Craft CMS. More info on http://craftsnippets.com/articles/testing-and-debugging-emails-sent-by-craft-cms-using-mailtrap
<?php
return [
'components' => [
'mailer' => function() {
$settings = \craft\helpers\App::mailSettings();
$settings->transportType = \craft\mail\transportadapters\Smtp::class;
$settings->transportSettings = [
'useAuthentication' => true,
'host' => getenv('SMTP_HOST'),
'port' => getenv('SMTP_PORT'),
'username' => getenv('SMTP_USERNAME'),
'password' => getenv('SMTP_PASSWORD'),
];
$config = \craft\helpers\App::mailerConfig($settings);
return Craft::createObject($config);
},
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment