Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKate Butler <kate@innocraft.com>2019-05-24 07:42:45 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2019-05-24 07:42:44 +0300
commitb9df06dadfd8030401bb9ae1b8126e4cf13f33b5 (patch)
tree75bcc95d0240817f854986d70cf86f49307ca059 /plugins
parent008530ed05a7d09f8fa0325ac28a10d500da7791 (diff)
New command to send test emails (#14467)
* New console command to send a test email * Use noreply email address as sender * Update email template
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CoreConsole/Commands/TestEmail.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/CoreConsole/Commands/TestEmail.php b/plugins/CoreConsole/Commands/TestEmail.php
new file mode 100644
index 0000000000..6eec81c48e
--- /dev/null
+++ b/plugins/CoreConsole/Commands/TestEmail.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link http://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Plugins\CoreConsole\Commands;
+
+use Piwik\Config;
+use Piwik\Mail;
+use Piwik\Plugin\ConsoleCommand;
+use Piwik\SettingsPiwik;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ */
+class TestEmail extends ConsoleCommand
+{
+ protected function configure()
+ {
+ $this->setName('core:test-email');
+ $this->setDescription('Send a test email');
+ $this->addArgument('emailAddress', InputArgument::REQUIRED, 'The destination email address');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $config = Config::getInstance();
+
+ $email = $input->getArgument('emailAddress');
+ $matomoUrl = SettingsPiwik::getPiwikUrl();
+ $body = "Hello, world! <br/> This is a test email sent from $matomoUrl";
+ $subject = "This is a test email sent from $matomoUrl";
+
+ $mail = new Mail();
+ $mail->addTo($email, 'Matomo User');
+ $mail->setFrom($config->General['noreply_email_address'], $config->General['noreply_email_name']);
+ $mail->setSubject($subject);
+ $mail->setWrappedHtmlBody($body);
+ $mail->send();
+ $output->writeln('Message sent to ' . $email);
+ }
+}