“All mail clients suck. This one [mutt] just sucks less.” Michael Elkins, ca. 1995

Actually I have tried a lot of desktop email clients (viz., Outlook, thunderbird, seamonkey, sylpheed, pine, alpine, claws email, kmail, evolution, opera) and in the long run they all starts sucking at the RAM. Now to be precise, I must tell you that it’s not a full-fledged mail-transfer agent (MTA), but rather a mail user agent (MUA), i.e. just an email client just like those previously mentioned.

Step 1: Create a password file, say ~/.secret/.passwd. Enter the passwords in it as follows and save the file (don’t worry, we’re going to encrypt it soon!):

GMail:    passwd1
Yahoo: passwd2

Step 2: Now encrypt the file with your gpg key (refer to the previous post for details). Don’t forget to delete the unencrypted file.

$ cd ~/.secret
$ gpg -e .passwd -o .passwd.gpg
$ rm -f .passwd

Step 3a: back to the home direcotory and modify the ~/.muttrc file: (you may equivalently do the same in ~/.mutt/muttrc)

# Process the password files first
#-------------------------------------
set my_tmpsecret=`gpg -o ~/.secret/.tmp -d ~/.secret/.passwd.gpg`
set my_gpass=`awk '/GMail:/ {print $2}' ~/.secret/.tmp`
set my_ypass=`awk '/Yahoo:/ {print $2}' ~/.secret/.tmp`
set my_del=`rm -f ~/.secret/.tmp`

Note: All user-defined variable must start with “my_”.

Step 3b: Now set up mutt for IMAP: (let’s say for GMail)

set imap_user="gmail.username@gmail.com"
set imap_pass=$my_gpass
set folder="imaps://gmail.username@imap.gmail.com:993/"
set spoolfile="+INBOX"
set postponed="+[Gmail]/Drafts"
set record=+[Gmail]/"Sent Mail"

Step 3c: Now let’s say we want to use Yahoo’s SMTP service to send emails: here’s how to set it up in ~/.muttrc:

set smtp_pass=$my_ypass
set smtp_url = "smtp://smtp.yahoo.com:587" # using port 587 for TLS
set from="yahoo_username@yahoo.com"
set realname="Your Real_Name"

Step 3d: Set your favorite editor to compose emails next in ~/.muttrc (mine is vim, so….)

set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set nocp" -c "?^$"'

Step 3e: Other necessary things to put in ~/.muttrc:

set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates

Step 3f: Now time for some pretty color: (add these too to ~/.muttrc)

1
2
3
4
5
6
7
8
color  body            brightyellow    black    (((ht|f)tps?)|mailto):(//)?[^\ "\t]*|www\.[-a-z0-9.]+)[^\ .,;\t>">]
mono   body            bold                     (((ht|f)tps?)|mailto):(//)?[^\ "\t]*|www\.[-a-z0-9.]+)[^\ .,;\t>">]
color  body            brightmagenta   black   "[-a-z_0-9.]+@[-a-z_0-9.]+"
mono   body            bold                    "[-a-z_0-9.]+@[-a-z_0-9.]+"
color  body            brightyellow    black   "^Good signature"
mono   body            bold                    "^Good signature"
color  body            brightwhite     red     "^Bad signature from.*"
mono   body            bold                    "^Bad signature from.*"

Step 3g: Some other customizations to put in ~/.muttrc:

set smart_wrap = yes
set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed
#
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
#
set timeout=60 #Check for mail every minute
set mail_check=5

Step 3h: Now save the file in your home directory and make it readable by none but the current user (you of course!):

$ chmod 700 ~/.muttrc

Step 4:Next create the these two directories to save mutt related stuffs:

$ mkdir .mutt
$ mkdir .mutt/cache

Step 5:To render the HTML/etc messages correctly create another file ~/.mailcap with the following as its content make it readable by you only (use chmod as above)

text/html; lynx -dump %s ; copiousoutput

Change lynx to links/links2/elinks depending what you actually have on your system.

Things to do:
I still cannot use multiple IMAP inboxes at a time — the account-hook / folder-hook does not seem to work. I need to spend some more time on it.

Here’s how to use multiple IMAP accounts in mutt.

References for this post: Crunchbang Linux site (my latest favorite distro!),muttrc builder, and mutt.org, of course. Another old reference from the days when mutt wouldn’t do SMTP. Also look at the references at the end of this wikipedia page. To build mutt from the source, refer to this.

References for to-do: Derkellerand mutt-users forum (from 2002!).

转自:https://nixtricks.wordpress.com/2010/05/05/mutt-configure-mutt-to-receive-email-via-imap-and-send-via-smtp/#comment-3098

[mutt] Configure mutt to receive email via IMAP and send via SMTP的更多相关文章

  1. VMWare虚拟机实例拷贝到另一台服务器后出现Error in the RPC receive loop: RpcIn: Unable to send.错误的解决

    把一个VMWare虚拟机实例拷贝到另一台服务器后,在事件查看器中的应用程序日志中不断出现Error in the RPC receive loop: RpcIn: Unable to send.错误, ...

  2. 邮件发送失败问题:Sending the email to the following server failed : smtp.qiye.163.com:25

    [邮件发送错误] : Sending the email to the following server failed : smtp.qiye.163.com:25, {}org.apache.com ...

  3. 解决Odoo出现的Unable to send email, please configure the sender's email address or alias.

    这是由于当前登录用户的邮件地址信息缺失造成的,需要设置其邮件地址. 方法:使用创建该用户的管理员帐号登录系统,开启技术特性,在需要设置邮箱地址的用户界面点击相关的业务伙伴标签链接,如图所示:

  4. Powershell Mail module, 发送outbox 里的全部邮件(一个.csv文件代表一封邮件)

    把creating mail代码写到调用处,往outbox写入 mailxxx.csv文件,入面记录了邮件的主要内容 写入 #template $TMP = IMPORT-CSV "$($d ...

  5. cetos6配置用msmtp和mutt发邮件(阿里云)

    Linux下可以直接用mail命令发送邮件,但是发件人是user@servername,如果机器没有外网的dns,其他人就无法回复.此时,有一个可以使用网络免费邮箱服务的邮件发送程序就比较重要了.ms ...

  6. L05-Linux部署msmtp+mutt发送邮件

    一.前言 首先,得明白发送一封邮件的流程,下面一段理论摘抄自廖雪峰的官网网站https://www.liaoxuefeng.com/article/00137387674890099a71c04005 ...

  7. 使用mutt+msmtp在Linux命令行界面下发邮件(续)

    一年前写过一篇<使用mutt+msmtp在Linux命令行界面下发邮件>,但是最近想照着文中的办法解决新的问题时发现又有新的疑惑了,所以就有了今天这篇“续集”. 首先说说msmtp.如果你 ...

  8. Zabbix利用msmtp+mutt发送邮件报警

    操作系统:CentOS 7 Web环境:Nginx+MySQL+PHP zabbix版本:zabbix-2.4.8.tar.gz 邮件服务:msmtp-1.4.32.tar.bz2     #http ...

  9. [svc]msmtp+mutt发附件,发邮件给多个人

    环境:centos6.7 x86-64 内网有web服务器(curl可展示目录) #预安装软件 yum install lrzsz ntpdate sysstat dos2unix wget teln ...

随机推荐

  1. Web App、Hybrid App、 Native App

    1.特点: 1. 偏交互的Native,偏浏览的Web:交互指复杂操作,输入/选择什么的2. 已稳定的Native,试错中的Web:H5页面用来做低成本验证很好3. 访问硬件Native,信息展示We ...

  2. SPSS学习系列之SPSS Statistics的菜单栏介绍(图文详解)

    不多说,直接上干货! 以下是菜单栏 1.以下是文件栏: 2.以下是编辑栏 3.以下是查看栏   4.以下是数据栏: 5.以下是转换栏: 6.以下是分析栏: 7.以下是直销栏: 8.以下是图形栏: 9. ...

  3. git 学习之基本概念

    在学习 Git 的时候我们经常会听到工作区,版本库,暂存区.那么这些东西指的是什么呢?本次我们就一起学习一下. 工作区 顾名思义:工作的区域,那么你一般在哪工作呢?当然是你本地可以看到的目录啦! 版本 ...

  4. [中英对照]Introduction to Remote Direct Memory Access (RDMA) | RDMA概述

    前言: 什么是RDMA? 简单来说,RDMA就是指不通过操作系统(OS)内核以及TCP/IP协议栈在网络上传输数据,因此延迟(latency)非常低,CPU消耗非常少. 下面给出一篇简单介绍RDMA的 ...

  5. background-position 详解

    一.语法 语法:background-position:x, y; 定义:背景图片相对容器原点的起始位置: 取值:     关键字:top | center | bottom | left | cen ...

  6. 深入理解 flex 布局以及计算_Flexbox, Layout

    起因 对于Flex布局,阅读了 大漠老师和其他老师写的文章后,我还是不太理解Flexbox是如何弹性的计算子级项目的大小以及一些其他细节.在大漠老师的帮助下,我去查阅Flexbox 的 W3C 规范文 ...

  7. PL/SQL之异常

    异常分为预定义异常和用户自定义异常.预定义异常是由系统定义的异常.由于他们已在STANDARD包中预定义了,因此,这些预定义异常可以直接在程序中使用,而不用在预定义部分声明.而用户自定义异常则需要在定 ...

  8. HDU 2680(最短路)(多个起始点)

    这道题也是死命TLE.. http://acm.hdu.edu.cn/showproblem.php?pid=2680 /* 使用pair代替结构 */ #include <iostream&g ...

  9. 基于 java 【Web安全】文件上传漏洞及目录遍历攻击

    前言:web安全之文件上传漏洞,顺带讲一下目录遍历攻击.本文基于 java 写了一个示例. 原理 在上网的过程中,我们经常会将一些如图片.压缩包之类的文件上传到远端服务器进行保存.文件上传攻击指的是恶 ...

  10. RESTful api 设计规范

    该仓库整理了目前比较流行的 RESTful api 设计规范,为了方便讨论规范带来的问题及争议,现把该文档托管于 Github,欢迎大家补充!! Table of Contents RESTful A ...