Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: terminal command to send test emails #4020

Closed
billythekid opened this issue Mar 20, 2019 · 4 comments
Closed

FR: terminal command to send test emails #4020

billythekid opened this issue Mar 20, 2019 · 4 comments
Labels
enhancement improvements to existing features site development 👩‍💻 features related to website/API development

Comments

@billythekid
Copy link
Contributor

billythekid commented Mar 20, 2019

It would be nice to have a terminal command to send test emails for the instances where we're overriding email settings in app.php with different configurations for environments etc.

At the moment to send a test email from the dashboard you need to fill in settings and it uses those, even if they're being overridden.

A command in terminal could solve this, something like;

./craft email/test [[email protected]] [environment]

@gtettelaar
Copy link
Contributor

@billythekid Just finished an idea for this over at #4407 but not entirely sure about one thing.

What specifically did you mean by testing for specific environments? Do you mean in the console command you want to select staging, dev, production e.t.c and an email will be sent using the config settings as defined by that environment in app.php or just enter custom transport adapter options to use for testing your email settings and their integration with Craft? Thanks!

@billythekid
Copy link
Contributor Author

@gtettelaar Yeah, I set dev and staging environments to use specific mailer components (usually mailtrap) and just set them in app.php…

/* app.php */
return [
    '*'          => [
        'modules' => [
            'my-module' => \modules\Module::class,
        ],
      //'bootstrap' => ['my-module'],
    ],

  // Dev environment settings
    'dev'        => [
        '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);
            },
        ],
    ],

  // Staging environment settings
    'staging'    => [
        '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);
            },
        ],
    ],

  // Production environment settings
    'production' => [
    ],
];

You'll see I don't bother with production mailer component because, depending on the site/client it could be any of local/smtp/mailgun/postmark/mandrill/whatever so for production I actually set it up in the normal dashboard way.

I'd either like the console command to just know, or have passed to it as a parameter, what environment it's in and use those settings, regardless of what's filled in in email settings on the site.

Does this help clarify it?

@gtettelaar
Copy link
Contributor

gtettelaar commented Jun 14, 2019

@billythekid That makes sense. It will be a selection you can make (I.E. Which env you want to use) which will be asked once you run the console command. I'll implement that over the weekend in the PR I mentioned above. Thanks for your help!

@angrybrad
Copy link
Member

Resolved in #4407

@brandonkelly brandonkelly added this to the 3.2 milestone Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvements to existing features site development 👩‍💻 features related to website/API development
Projects
None yet
Development

No branches or pull requests

4 participants