Configure console email client mutt with Zimbra as IMAP/SMTP server

This is actually a an extended version of a post I did in 2009 titled Configure mutt for Zimbra and IMAP but this time I have added more options to the mutt config file.This example was tested on a Ubuntu 10.04 LTS server with Zimbra version 8.0.5 but will most likely be working on other versions as well.First you need to install the mutt email client.Next you need to configure mutt so that it knows where to look for emails.My config file ~/.mutt/muttrc file looks something like this

set copy="yes"                           # Save sent mail on Zimbra
set from="username@mail.example.com"     # Your email 
set folder="imaps://mail.example.com"    # The remote Zimbra IMAP URI
set imap_idle="yes"                      # Use IMAP IDLE for pushing mail
set imap_user="username"                 # Your IMAP username
set mail_check="60"                      # Poll every 60 seconds rather than waiting 24 minutes for new mail
set postponed="+Drafts"                  # Saving postponed messages on Zimbra for later
set realname="First Last"                # Your first name and last name
set record="+Sent"                       # Save sent mail to "/Sent" on Zimbra
set reverse_alias="yes"                  # If email is saved in your alias file, show the name of the mail 
set signature="~/.mutt/sig.txt"          # Your email signature, if any
set smtp_url="smtps://username@mail.example.com:465" # The SMTPS URI for sending mail
set sort_alias="alias"                   # Sort the alias file by alias
set spoolfile="imaps://mail.example.com/Inbox" # Where your inbox is located on Zimbra
set ssl_force_tls="yes"                  # Force TLS rather than SSL. Supercedes "
set ssl_starttls"
source ~/.mutt/aliases                   # Alias file to store your "address book"
source ~/.mutt/lists                     # Store any mailing lists here, and respond to the list, rather than "reply to all"Create the file if it does not already exist
$ touch ~/.mutt/muttrc

mutt will complain about missing files mentioned in the configuration above if you do not create them first

$ touch ~/.mutt/sig.txt$ touch ~/.mutt/aliases
$ touch ~/.mutt/lists

You are now ready to start mutt as a console email client.

PS
This setup will request for your password every time you start mutt and every time you send email.
This post does not describe how you can have mutt to remember your encrypted password using GPG key.
I have added some extra configuration (~/.mutt/muttrc) in addition to the code above but that is not required but I have found it useful

 
set askbcc="yes"                         # Ask for Bcc: recipients when composing a message
set askcc="yes"                          # Ask for Cc: recipients when composing a message
set charset="utf-8"                      # Set the character encoding to UTF8
set certificate_file="~/.mutt/certs"     # SASL2 certificate location
set edit_headers="yes"                   # Edit the headers when composing a message
set envelope_from="yes"                  # Use quoted-printable encoded message when "From " is at the beginning of a line
set header_cache="~/.mutt/cache/headers" # Location to save cached mail headers
set hostname="mail.example.com"          # Set your hostname in the headers
set imap_check_subscribed="yes"          # Check 'subscribed' folders only
set message_cachedir="~/.mutt/cache/bodies" # Location to save cached mail bodies
set message_cache_clean="yes"            # Delete cache files if deleted off the server
set move="no"                            # Don't move read mail
set pager_index_lines="11"               # Show 11 lines of the index when reading messages
set quote_regexp="^([ \t]*[|>:}])+"      # Quoted messages (get rid of '#' which is in the default
set use_from                             # Allow me to switch email addresses in my editor
set sort=threadsset 
set sort_browser=dateset 
set sort_aux=reverse-last-date-received  # Set editor with automatic line wrapping at 75 characters
set editor="vim"
set textwidth=75 wrap'"

The header_cache is useful to speed the startup because you do not need to read all the mails in the Inbox every time you start mutt.

How to configure postfix virtual domains

I will assume that your postfix configuration directory is /etc/postfix and your postfix version is around 2.0.14

1. Edit /etc/postfix/virtual This is a plaintext file where you can specify the domains and users to accept mail for. Each virtual domain should begin with a single line containing the domain name. The subsequent lines define addresses at the domain that are deliverable. Mail will be delivered to local usernames on the right side, as demonstrated in the example below. The condition @domain allows you to deliver “all other” mail to the indicated user. You can list multiple domains in this file; just repeat the format demonstrated below.

example.com		this-text-is-ignored
postmaster@example.com	postmaster
address1@example.com	destuser1
address2@example.com	destuser2
@example.com		destuser1

2. Edit /etc/postfix/main.cf

You have to tell postfix where to look for these virtual alias mappings; the appropriate configuration directive is in the main postfix configuration file. This tells postfix to use the db-format (hash) version of your virtual mappings. Note that your system must have db support for this to work; also, the actual db file is not created until you run ‘postmap’ in step 3.

virtual_alias_maps = hash:/etc/postfix/virtual

3. Refresh configuration and mappings

Since you’ve changed main.cf, you should restart the daemon. The second command below updates the virtual mappings; you must run this ‘postmap’ command when you change your /etc/postfix/virtual file. The ‘postmap’ command actually creates the hash db file that postfix looks for.

postfix reload
postmap /etc/postfix/virtual

Now try delivering mail to virtual domain addresses. If you encounter problems, check your mailer daemon system log and make sure your server configuration has been refreshed with ‘postfix reload’ and the ‘postmap’ commands.

Generering av SSL sertificat

Dovecot og Courier-imap klager til tider på at sertifikat ikke fungerer. Da kan man kjøre følgende kommando for å lage nytt sertifikat. Kommandoen kjøres fra /etc/ssl/dovecot/

openssl req -new -x509 -nodes -days 365 -out cert.crt -keyout cert.key
cat cert.key cert.crt > cert.pem

Endre navnet på filene slik at de stemmer overns med configfilene til de respektive programmene.