June 18, 2024

Set up msmtp to queue sent emails’ when you are offline

When your computer isn’t connected to the internet, you can use msmtpq to queue emails that you would like to sent once the computer is connected to internet again. As soon as your computer is connected, all you have to is run the command $ queue-msmtpq -r and all emails queued will be sent (you can also select which queued emails you’d like to send).

To set up msmtpq I followed /usr/share/doc/msmtp/examples/msmtpq/README.msmtpq and the short section on msmtpq of a blog post titled Msmtp: A simple mail transfer agent.

Below I describe the steps I took.

Copy the following files:

sudo cp /usr/share/doc/msmtp/examples/msmtpq/msmtpq /usr/local/bin/
sudo cp /usr/share/doc/msmtp/examples/msmtpq/msmtp-queue /usr/local/bin/

Update the following line in .muttrc:

set sendmail ="/usr/local/bin/msmtpq" 

Add the following line in .muttrc:

set sendmail_wait = -1


$ mkdir .msmtp/mailqueue/msmtpq 
$ touch .msmtp/mailqueue/msmtpq
$ echo > .msmtp/mailqueue/msmtpq << EOF

You might need to update file permissions, check Msmtp: A simple mail transfer agent.

In /usr/local/bin/msmtpq update:




To test msmtpq, disconnect from the internet and send an email. Mutt should print Mail sent on the prompt, at the bottom.

To check that the email was queued, run:

$ msmtp-queue

The terminal should print something like:

  mail  num=[ 1 ]  id=[ 2024-06-13-18.11.00 ]
From: JD <j@d.com>
To: j@d.com
Subject: test msmtpq


In ~/.bash_aliases I added:

alias queue='msmtp-queue'

I can pass the option msmtp-queue offers to the alias fine e.g. queue -h.

personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki msmtp mutt offline

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88