Configure mutt to send email from Google Apps gmail account

This illustrates how to setup mutt so that it sends email from a Google Apps gmail account. Alternately, you can just use a Gmail regular account.

First install mutt:
On Debian:
apt-get install mutt

Now, create a folder for mutt:
mkdir -p /.mutt/cache

Now, edit ~/.muttrc file (it may not exist):
emacs ~/.muttrc

It should have the following contents:

account-hook imap://gmail/ “set
set from = "[email protected]"
set realname = "Server Mailer"
set imap_user = "[email protected]"
set imap_pass = "Be4!testpass"
set folder = "imaps://"
set spoolfile = "+INBOX"
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:[email protected]"
set smtp_pass = "Be4!testpass"
set move = no
set imap_keepalive = 900

In the above example mutt configuration file, I had already created a Google Apps Mail account [email protected], with the password “Be4!testpass”. Of course you should set a more complex password.

Create a test message:

emacs /tmp/message.txt

Now try sending a mail to yourself to test:
mutt -s “Test from mutt” [email protected] < /tmp/message.txt If you get the following error message: "SASL authentication failed, Could not send the message.", it means that there is a problem with the username or password. If it works, you should momentarily receive an email at the target email account that you specified. This is extremely useful, since it allows you to avoid installing a mail server on your VPS.

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.