DEV Community

Cover image for Automatically send emails using Google SMTP with 3 easy steps
Steve Whitmore
Steve Whitmore

Posted on • Updated on


Automatically send emails using Google SMTP with 3 easy steps

If you need to automate tasks then you'll likely find this post useful. I like to be notified if an automated script fails or succeeds, depending on the situation.

You can get your scripts to email you using Google's SMTP server:

1. Set up a Gmail Password

Assuming you have a Google account and are signed in, visit

Select "Other" from the Select app drop down:

Google app password landing page

Give the app password a name. It can be whatever. Click "Generate" and you'll see something like this:

Google app password generated

Save this somewhere else it shall be lost to the void.

When you click done your new app password will show up for you:

Google app password saved

2. Install mutt

If you're on Linux your distro will likely have the mutt package available in its repositories:


sudo dnf install mutt


sudo yum install mutt


sudo apt install mutt


sudo pacman -S mutt

Bonus: mutt is also available on MacOS via Homebrew:

brew install mutt

3. Configure mutt

Create a .muttrc file in your home directory.

vi ~/.muttrc

Fill it out with the configs, pasting in your app password from step 1 for the smtp_pass value:

set from = "<gmail-id>"
set realname = "<Your Name>"
set smtp_url = "smtp://<gmail-id>"
set smtp_pass = "<smtp password generated in the google link above>"
Enter fullscreen mode Exit fullscreen mode

In our case "smtp password generated in the google link above" is vaykiyyakisiqmez.

Now test it out -

echo "This is an email body." | mutt -s "This is an email subject"

Tada! πŸŽ‰

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git