---
title: "Testing Sending Email Using Platform Email From Drupal and the Command Line"
date: "2022-11-10T14:02:47+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/93356-testing-sending-email-using-platform-email-drupal-and-command-line"
id: "d8d5d950-301c-4726-b7e3-add19e2ba269"
---

Table of contents will be added

​There are multiple ways to test whether email is sending from your environment. This assumes that you've [successfully verified one or more domains, and have turned on Platform Email for the environment you're working on](/node/56305).

From the command line:
----------------------

Note that his only tests whether your environment can send mail, not necessarily Drupal.

    echo Test email | mail -s "Test email." "your-email-address@example.com" -r "from-address@verified-platform-email-domain.com"

Using the PHP command line:
---------------------------

Note that this only tests whether PHP can send email, not necessarily Drupal

    php -r 'mail("your-email-address@example.com", "Test email.", "Body of the email", "From: from-address@verified-platform-email-domain.com");'

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:

*   See [https://github.com/stevenlafl/drush-email](https://github.com/stevenlafl/drush-email) and [https://www.drupal.org/project/drush\_extras/issues/1770582](https://www.drupal.org/project/drush_extras/issues/1770582) for ideas on how to do this in Drupal 7.

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 = "your-email-address@example.com"; // 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.com

In all the examples above, Replace `your-email-address@example.com` 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 that, and receiving an email, we have [instructions on how to verify the email itself was sent by Platform Email by looking the headers](https://acquia.my.site.com/s/article/4416271155479-Confirming-your-current-Acquia-Email-service).