This guide covers how to dynamically send emails in the Minds backend.
- An event occurs (e.g. a new user joins Minds) and dispatches a message to the queue
- The queue then dispatches an internal event
- The internal event compiles and dispatches the email
- Mailer.php does the actual sending
You can also use/extend optional EmailStyles.php and partials (reusable snippets that get built and injected into the email) for additional control over styles. See SuggestedChannels.php and SuggestedChannels.tpl for partial usage examples.
To actually send and test, add your own gmail SMTP server to
$CONFIG->set('email', [ 'smtp' => [ 'host' => 'smtp.gmail.com', 'username' => '[email protected]', 'password' => 'my gmail password', 'port' => 465 ] ]);
Ensure your gmail account is configured to allow emails to send. 2-step verification must be turned OFF. In 'connected apps and sites', turn ON 'allow less secure apps'. Additional info here.
Make sure runners are running so the queue can be parsed:
docker-compose up runners
See Email CLI controllers for tools related to testing and building. For example, to test the WelcomeComplete email, run this in the php-fpm shell:
php cli.php Email testWelcomeComplete --guid=1095036819759697938 --output=/var/www/Minds/engine/welcome_complete.html --send
Run this to get additional information about the parameters involved in the test:
php cli.php Email testWelcomeComplete --help