Offline Mutt to replace Thunderbird on Ubuntu (3 of 4)

The previous post looked at setting up offlineimap for managing received emails, and this post will look at setting up msmtp for managing sending emails.

The main reason I don’t like to use Mutt’s built-in SMTP to send directly to Google Mail’s server is that it’s slow. It might not be slow for you, but it’s slow for me. I want to hit Send and for the email to be gone. And msmtp does that for me.

After installing the msmtp package, a very small and simple config is needed which should be saved as .msmtprc in your home folder:

# Multiple accounts are supported, but some changes will need to be made
account default                                                                                                                    
host smtp.gmail.com
port 587
protocol smtp
auth on
# These two values should be the same
# These can be 'user@gmail.com' or any domain registered with Google Apps with
# active Mail settings
from user@domain.com
user user@domain.com
# Change this
password xxxxxxxx
tls on
tls_nocertcheck

As msmtp will queue all emails and send them periodically, a few scripts can be used to help managed this. On Ubuntu this will be in /usr/share/doc/msmtp/examples/msmtpqueue/ and it’s worth copying all three *.sh files to somewhere in your path. For me, that’s /usr/local/bin.

-rwxr-xr-x 1 root root 1078 Mar 11  2011 msmtp-enqueue.sh*
-rwxr-xr-x 1 root root  175 Mar 11  2011 msmtp-listqueue.sh*
-rwxr-xr-x 1 root root 1228 Mar 11  2011 msmtp-runqueue.sh*

As msmtp-runqueue.sh is used to deliver emails, it needs to be set up on a cronjob that looks like this:

* * * * * /usr/local/bin/msmtp-runqueue.sh > /dev/null 2>&1 

The script exits if it is already running, so it’s safe to run this every minute. And msmtp-listqueue.sh can be used to check the current queue at any time, if you feel the need.

In the next article I’ll bring this all together with a Mutt config to use offlineimap and msmtp.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackbacks and Pingbacks: