Using Mutt with Mac to read Office 365 IMAP account
I love using lightweight software to do simple tasks, I mean why on earth would you like to use bloated software to perform easy tasks like reading and writing emails?
That is why I decided to use mutt when on my Mac to read my personal email account.
Here is my setup.
- Office 365 Exchange account (Just because it is not expensive and supports ActiveSync)
- Mutt on my Mac to read and write while working on the computer
- Postfix configured to work with a SmartHost for sending emails
I have installed mutt using Homebrew.
brew install mutt
If you are on Ubuntu,
sudo apt-get install mutt will work.
We know need to configure mutt to work with your IMAP account.
#Authentication set imap_user=“user@domain” #your IMAP user name or login set imap_pass=“password” #your IMAP password set smtp_authenticators="login" set ssl_use_sslv3=yes set timeout=15
I know it is not a good idea to put your password in a simple text file, but I am the only one with access to this computer and if I lost it, I have my hard drive encrypted using FileVault. In my Ubuntu machine I have my home folder encrypted too. If you really are paranoid you can of course leave imap_pass unset and mutt will ask for your password.
#IMAP set mbox="imap://outlook.office365.com/INBOX" set postponed="imap://outlook.office365.com/Drafts" set spoolfile="imap://outlook.office365.com/INBOX" set folder="imap://outlook.office365.com/" set record="imap://outlook.office365.com/Sent Items" #set trash="imap://outlook.office365.com/Deleted Items" mailboxes
Pretty self explanatory, but the trash variable can not be used on my Mac, as the version from brew was not compiled with it, so, the emails I delete on mutt are gone forever as soon as I close Mutt. I am OK with that.
#SMTP #set smtp_url="smtp://user@email@example.com:587/" #set smtp_pass=“password” set smtp_url="smtp://localhost/" set from="firstname.lastname@example.org" set realname="Guillermo Garron"
As you can see, smtp_url and smtp_pass are commented, that is as I said I am relying on local Postfix to deliver my emails, this is because if I loss Internet connectivity while writing my email I do not want Mutt waiting forever for the connection. That is Postfix’s job.
Now is the turn for Postfix, I have set it up to work with Office 365 STMP server so my mails are not bounced depending on the IP.
biff = no command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb $daemon_directory/$process_name $process_id & sleep 5 dovecot_destination_recipient_limit = 1 html_directory = /usr/share/doc/postfix/html imap_submit_cred_file = inet_interfaces = loopback-only inet_protocols = ipv4 mail_owner = _postfix mailbox_size_limit = 0 mailq_path = /usr/bin/mailq manpage_directory = /usr/share/man message_size_limit = 10485760 mydomain_fallback = localhost mynetworks = 127.0.0.0/8, [::1]/128 newaliases_path = /usr/bin/newaliases queue_directory = /private/var/spool/postfix readme_directory = /usr/share/doc/postfix recipient_delimiter = + relayhost = [smtp.office365.com]:587 sample_directory = /usr/share/doc/postfix/examples sendmail_path = /usr/sbin/sendmail setgid_group = _postdrop smtp_generic_maps = hash:/etc/postfix/generic smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_password smtp_sasl_security_options = noanonymous smtp_use_tls = yes smtpd_client_restrictions = permit_mynetworks permit_sasl_authenticated permit smtpd_tls_ciphers = medium smtpd_tls_exclude_ciphers = SSLv2, aNULL, ADH, eNULL tls_random_source = dev:/dev/urandom unknown_local_recipient_reject_code = 550 use_sacl_cache = yes
There are two more steps before it is ready.
/etc/postfix/sasl_password file something like this:
sudo postmap /etc/postfix/sasl_password
Finally add this line to
sudo postmap /etc/postfix/generic
That is it, you now just have to restart Postfix
sudo postfix reload
And start using Mutt.