A simple set of scripts/units for queuing and sending messages with msmtp.
README
A simple set of scripts/units for queuing and sending messages with msmtp.
msmtpqis a drop-in replacement formsmtpto queue an outgoing
message. It never blocks and never actually sends messages.msmtpq-flushsends reliably queued messages.msmtpq-queueshows information about queued messages.
Motivation
Upstream msmtp comes with not one but two different offline queue mail sending queue scripts. Unfortunately:
- The older one is simpler and easier to understand, but also less well maintained.
- The newer one tries to do way too much and that makes me nervous.
- Both use lock "files" instead of advisory locks. I don't want my mail queue to get stuck any time my queue flushing process gets killed while attempting to flush the queue.
- Neither use follow the XDG spec.
- They don't provide systemd integration.
Usage
- Send messages with
msmtpqinstead ofmsmtp. - Install and enable the provided systemd units to automatically flush queued
messages. - Use
msmtmpq-queueto see information about the messages.-hhelp / usage-cprint count of queued messages and exit-finclude the full message file path
Systemd Units
msmtp-queue.service- Invokes msmtpq-flush to flush queued messages, if any.msmtp-queue.timer- Invokes msmtp-queue.service every 10 minutes. This will
allow you to send mail while offline.msmtp-queue.path- Invokes msmtp-queue.service immediately when a message is
queued. This is the fast-path for sending mail immediately you're online.
These scripts really shouldn't ever eat your mail although you may end up
sending the same email twice on very rare occasions. However, if you send a
message while offline, they'll only re-try once every 10 minutes.
Also note, these scripts look for/put configs/logs in non-standard directories:
- LOG:
$XDG_STATE_HOME/msmtp/queue.log($XDG_STATE_HOMEdefaults to~/.local/state). - QUEUE_DIR (mail queue):
$XDG_DATA_HOME/msmtp/queue.
These are defined as variables at the top of the provided scripts.
Installation
This is a highly simplified script assuming you already have the above-mentioned
msmtp config file and set up XDG variables.
git clone https://github.com/Stebalien/msmtp-queue.git /tmp/msmtpq
sudo cp /tmp/msmtpq/msmtpq* /usr/local/bin
mkdir -p ~/.config/systemd/user $XDG_DATA_HOME/mail.queue
cp /tmp/msmtpq/systemd/msmtp-queue.* ~/.config/systemd/user
systemctl --user enable msmtp-queue.path msmtp-queue.timer
Afterwards, update your mutt configuration to use msmtpq instead of msmtp.
MacOS
This fork maintains a MacOS/homebrew port.
