Sending e-mail from your OSMC Pi with Mutt and Gmail


I didn’t see a tip/tricks thread, but I wanted to leave a few for posterity and future refernce

This is a simple way to send mails from the command line using a Gmail account. No need to install any mailservers or other bloat.

Why would you want to do this? Well, it’s an easy way to send e-mail notifications from scripts.
For example, I am using the Pi not only for Kodi, but as as a central fileserver. I set-up some scripts and cron-jobs to auto-sync chosen directories and e-mail me upon success or error.
For this purpose I set-up a separate/throwaway Gmail account for my pi.

Mutt is a very capable e-mail client, and is surprisingy pleasant to work with.

OK. Here we go:

sudo apt-get install openssl libsasl2-modules #Required for Gmail authentication
sudo apt-get install mutt

mkdir ./mutt/mails

Now edit .muttrc with your account details.

nano ~./muttrc

Paste the following into .muttrc , changing the username (3 instances) and password (2 instances).

set from = "" set realname = "username" set imap_user = "" set imap_pass = "password" set folder = "imaps://" set spoolfile = "+INBOX" set record="+[Gmail]/Sent Mail" set postponed ="+[Gmail]/Drafts" set header_cache =~/.mutt/cache/headers set message_cachedir =~/.mutt/cache/bodies set certificate_file =~/.mutt/certificates set smtp_url = "smtp://" set smtp_pass = "password" set move = no set imap_keepalive = 900 set record="~/.mutt/mails/sent"

Save and close .muttrc

send a test mail:
echo “This is the body text” | mutt -s “This is the subject line”

or to use the mutt interface
mutt -s “This is the subject line”

or just…mutt

Your first attempt should fail with “SASL authentication failed”, but Gmail will mail you to warn that a new device is trying to use your account.
To unblock it. Login to your gmail account in a browser and go to

1 Like

Hi Stim,

Thanks for the post.
Please, could you help me ?

I’m trying to configure it but I’m quite new and after made:

mkdir ./mutt/mails ---- couldn’t create the directory so I’ve created manually.

After tried :
nano ~./muttrc

I got an error “~./muttrc No such a file or directory”


mutt -v

Mutt 1.5.23 (2014-03-12)
Copyright © 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type mutt -vv'. Mutt is free software, and you are welcome to redistribute it under certain conditions; type mutt -vv’ for details.

System: Linux 3.18.13-1-osmc (armv7l)
ncurses: ncurses 5.9.20140913 (compiled with 5.9)
libidn: 1.29 (compiled with 1.29)
hcache backend: tokyocabinet 1.4.48


I also tried to run:
$ mutt

But I got: /var/mail/root
no such a file or directory mailbox (errno= 2)

Any help , would be too much appreciated.


Any reason you chose Mutt over say, msmtp?


Hi Rata,

The mutt settings file is ~/.muttrc

nano ~/.muttrc

@Sam.: Mutt is just a personal preference - simple and nice :slight_smile:

Hi Sam,

No reason, Just saw the post of Stim and It looks like pretty straight forward… :smile:
But still not luck so far… :frowning:

Thanks for your help Stim!
I just edit as you said , it started to autenticate the account after I run $mutt but said login failed! :blush:

I have enabled on google accounts settings for app less secure and disable the double authentication but still login failed :’(

after tried
I made a new account and now is working!!! :smile: thanks Stim!!! :smiley:

Few things that are wrong :smile:

sudo mkdir .mutt

sudo mkdir .mutt/mails

I made it under /root

Good news! :smiley: