Send email via Drush

Created on 30 January 2025, 3 months ago

Problem/Motivation

Need to send email via the Drupal SMTP configuration from the drush command line

Steps to reproduce

There is currently no way to send email from the command line Drush tool that uses the SMTP settings configured in Drupal.

Proposed resolution

Add a Drush command smtp:send-mail (aliases: email, smtp-send).

Syntax:

$ drush help email
Sends an email via the SMTP module.

Arguments:
 recipient The recipient email address.                                     
 subject   The subject of the email.                                        
 [body]    The body of the email. If not provided, it will read from STDIN. 

Options:
 --no-newlines If provided, disables automatic conversion of '\n' to actual newlines. 

Examples:

# send as single command with body text
drush email recipient@example.com "My Subject" "This is the\nEmail Body\nIt Worked!"

# send the output of a stream (STDIN)
cat /etc/group | drush email recipient@example.com "My Subject"
 

Remaining tasks

none

User interface changes

none

API changes

none

Data model changes

none

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States diamondsea

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024