Multiple methods exist to test whether email is getting sent from your environment. To proceed, ensure that you have successfully verified one or more domains, and turned on Platform Email for the environment you're working on.
This method tests only whether your environment can send email. It does not tests whether Drupal can send email.
echo Test email | mail -s "Test email." "[email protected]" -r "[email protected]"This method tests only whether PHP can send email. It does not tests whether Drupal can send email.
php -r 'mail("[email protected]", "Test email.", "Body of the email", "From: [email protected]");'To test specifically whether Drupal can send email, see the following Drush command:
Using Drush for Drupal 7:
This requires a separate command file, though these are in the development stages:
Using Drush for Drupal 8 or 9:
drush php-eval '$mailManager = \Drupal::service("plugin.manager.mail");
$params["context"]["subject"] = "Test mail subject.";
$params["context"]["message"] = "Test mail message.";
$to = "[email protected]"; // Email address needs to be sent to
$langcode = "en"; // Change the language code if appropriate
$result = $mailManager->mail("system", "mail", $to, $langcode, $params);
if ($result["result"] !== true) {
echo t("There was a problem sending your mail and it was not sent.");
}
else {
echo t("Your message has been sent.");
}' -l your-site.comIn all these examples, replace [email protected] with a real recipient email address. The From address can be a no-reply address, but it must be a verified domain within the Platform Email settings. Note that the Drush example uses the site's main email address.
After running the command and receiving an email, you can review the headers and verify that the email itself is sent by Platform Email.