|
标题不能改了,还有procmail的配置文件,见五楼,五楼以下的配置为的是我用手机邮件给电脑发送指令所做的修改,希望高手教我,大拿们多多批评,懒人可以直接拿去用,如果对你有帮助,帮忙顶下,毕竟也用去我很多时间
八楼的作品大可改进,脚本我不太熟悉,哪个可以帮我改进一下
参考了一大堆贴子,总之搞定了mutt,,debian,ubuntu下getmail的名字为getmail4,这个要注意,配置也有些不同
配置代码里的邮箱名和密码都要改成自已的东西,我就不啰嗦了
第一步,安装必须的软件包,及创建相关的目录文件,呵呵如下可以做个最简单的脚本,本来,我想写一个完整的配置脚本,只是今天没时间了,有时间再做吧
#!/bin/bash
#安装软件
yum install -y msmtp getmail mutt ca-certificates
#切换到普通用户 abcd
su abcd
mkdir ~/Mail
mkdir -m 700 ~/Mail/inbox/{,tmp,new,cur}
mkdir ~/.getmail
cd ~/Mail
touch sent postponed .mutt.alias foxmail solidot
mkdir certs
cd certs
#下载密钥文件,这个在gmail是必须的,
wget Thawte_Premium_Server_CA.pem
wget http://www.adamjiang.com/Equifax_Secure_CA.pem
cd
第二部分,mutt配置文件,六楼有改进,针对接收手机指令的
1,定义变量,在.bashrc里写入如下代码,这个不知道能用不,至少我还没有用变量代替自己的邮箱名,可以在配置文件里找到这个变量了改过来就行
#这里假定用户名是google@gmail.com
#你可以改成自已的googleE-mail
gmail=google@gmail.com
2,mutt配置
vim ~/.muttrc 并写入如下代码
##颜色设置
color normal brightblue default
color attachment blue default
color error red white
color status white blue
color hdrdefault magenta default
color indicator black cyan
##
##发信设置
set sendmail="/usr/bin/msmtp"
set use_from=yes
set from=google@gmail.com
set envelope_from=yes
##
##设置默认编辑器 在vim保存这个临时文件时以mutt假定的编码保存。vim是强大的,
#强大总有强大的好处,只要你能掌握它的强大。我们可以为mutt中调用的 vim指定
#特殊的初始化文件,并在vim打开文件后进行一系列的针对这个文件的初始工作
set editor = 'vim -u ~/.mutt/vimrc "+set fileencoding=utf-8"
##设置信箱
###set mbox="~/Mail/receivebox"
set mbox="~/Mail/inbox"
set mbox_type=maildir
###set mbox_type=mbox ###设置为单文件存储方式,五楼以下采用,具说比用目录方式存储好一些
set spoolfile="~/Mail/inboxrc"
set postponed="~/Mail/postponed"
set record="~/Mail/sent"
##
macro index G "!getmail\n" "Invoke getmail"
macro pager G "!getmail\n" "Invoke getmail"
##
## 让mutt监视下面几个邮箱,并随时报告新邮件
mailboxes "=inbox"
mailboxes "=Gmail"
mailboxes "=receivebox"
set check_new = yes
set timeout = 600
### 这是一个格式字符串,用来控制你的index的列表显示。它的缺省定义是
set index_format="%4C %Z %{%b %d} %-15.15L (%4l) %s"
###指定你有哪 些信箱文件。当你按 "c" 切换信箱时,再按 Tab 键,这些信箱就可供你选择
mailboxes inbox sent-mail
### 这是一个 bool 型变量。它表明你在回信时引用原文是否加入原文的邮件头。
#set header=no
### 可以设置为 yes, no, ask-yes, 或者 ask-no.
### 这是说,当你按q退出时,是否提示你(ask-yes,ask-no),
### 还是直接就退出了(yes),还是根本不理你(no)。
set quit=yes
### 那些类型的附件是允许直接通过 .mailcap 浏览的?
##doc类型的附件通过wvware转成html 浏览
#auto_view text/plain application/x-gzip
###auto_view
###auto_view text/html w3m -dump -ppc 9 -I %{charset} -T text/html %s|uniq
auto_view image/*
###auto_view application/zip
###auto_view application/x-gzip
###auto_view application/x-gunzip
###auto_view application/pgp-signature
###auto_view application/pgp
###auto_view application/octet-stream
###auto_view application/x-zip-compressed
###auto_view application/x-arj-compressed
###auto_view application/x-tar-gz
###auto_view application/ms-tnef
###auto_view application/x-perl
###auto_view application/x-sh
###auto_view application/x-tcl
###auto_view application/x-delphi-source
###auto_view application/emacs-lisp
###auto_view application/msword
###auto_view text/x-patch
###auto_view text/html
###auto_view text/x-vcard
###auto_view text/x-script.elisp
###auto_view image/tiff
###auto_view text/x-lisp
### 这也是一个提示性变量。它是确定当你退出时,是否提示你把信件
###从spool 移动到的mbox 文件。
set move=no
### 当 Mutt 用 thread 方式显示时,是否用纯 ascii 表示树状列表。
set ascii_chars=yes
### 回信时是否包含原文。
###set include
### 回信的引文之前插入那个符号?
set indent_str="> "
### 设置你自己的邮件头。
my_hdr From: google@gmail.com
### 打分
### 新信件+4分,主题包含"通知"的+2,主题包含 "Circulation" +3, 已经标记
### 删除的 -5,上次没有读的 +1,包含 "believe"的 -10(垃圾广告!)。
score "~s jingwen" +10
score "~N" +4
score "~s 通知" +2
score "~s Circulation" +3
score "~D" -5
score "~O" +1
score "~s believe" -10
### 排序方式。
set sort=score
### 当用 thread 排序方式时,我们对各个 thread 的相对排序顺序。
set sort_aux=date
### 如果翻到最后,再按往下翻也不会翻到下一封信件
set pager_stop
### 如果设置,当你按 "r"
### 回信时,就不会再提示你输入回信地址和主题,直接进入编辑
###模式。
set fast_reply
### 当你按 "t" 或者 "D" 之类的标记操作时,是否自动把光标移动到下一封信件。
set resolve=yes
### 地址簿
source ~/Mail/.mutt.alias
### 当你在 index 里按 "a"
### 为来信者取别名时,使用哪一个别名文件保存这个别名。
set alias_file=/home/abcd/Mail/.mutt.alias
### 你发出的邮件保存n到那个信箱文件?比如可以像我这样每个月发出的信件放在不同的文件
##里。
set record="~/Mail/=sent-mail-`date +%Y-%m`"
### 你的终端支持哪一种编码的显示?这个必须和你的终端编码一样。
###注意这个如果设置不正确的话会导致在写邮件时出现一个"bad IDN"的错误信息
set charset="utf-8"
###:gb2312:gbk:us-ascii:iso-8859-1"
### send_charset
set send_charset="gb2312:us-ascii:iso-8859-1:gbk:utf-8"
### 外部程序退出时,是否要求用户按一个键才返回。这在察看某些shell命令输出时是比要>的,
### 否则它们一下就消失了。
set wait_key=no
### 当你要把信件存到另一个信箱,而这个信箱已经存在时,是否提示附加?
set noconfirmappend
### 是否把邮件头也放在编辑器里可以修改?
set edit_headers=no
### 当你在用 pager 看信件时,在 index 留出多少行显示邮件列表?
set pager_index_lines=4
### 告诉 Mutt 你已经订阅了那些邮件列表(mailing-list).
# subscribe fvwm@fvwm.org
### mutt显示日期为中文
set locale=`echo "${LC_ALL:-${LC_TIME:-${LANG}}}"`
### Chinaren 等服务器发出来的信件使用了 quoted-printable 的 subject,
### 而且设置编码为 "iso8859-1",这显然是错误的。
### 对付这个错误的办法是把 iso-8859-1 变成 gb2312 的别名
charset-hook ^iso-8859-1$ GB18030
###solidot发来的邮件为 乱码的解决办法,把us-ascii变成utf-8的别名
charset-hook ^us-ascii$ utf-8
### evolution 发过来的 subject 为 utf-8 编码的邮件标题乱码!
### 那就把不是 utf-8 的编码都映射到 gb2312
charset-hook !utf-8 GB18030
###charset-hook gb2312 utf-8
###按照标准每封邮件的邮件头都应该有一个Charset来表示这个邮件的 附件的编码,客户端则会用相应的Charset来解码附件,但如果这个邮 件没有这个域怎么办?mutt会尝试assumed_charset中的编码来尝试解 码
set assumed_charset = "GB18030:gb2312:gbk:utf-8"
###我的Locale是UTF-8的,但有时也不得不处理一些其他编码的文本文 件,如GB2312的。
#当我使用mutt来发送文本附件时,mutt会对其进行编 码的转换。这使得编码与当前
#的Locale不同的文本附近变成了乱码,为 此我们可以通过设置参数attach_charset来解决
set attach_charset = "GB18030:gb2312:gbk:utf-8"
###搜索中文关键字的时有某些邮件未能被检索到
set thorough_search=yes
#push后执行进入mutt后的按键动作
#push
第三部分,msmtp,发信设置
vim /etc/msmtprc 写入如下代码
defaults
tls on
auth on
logfile ~/Mail/.msmtplog
#tls_starttls off
#tls_trust_file /home/abcd/Mail/certs/Thawte_Premium_Server_CA.pem
account $USERNAME
tls_trust_file /etc/pki/tls/cert.pem
host smtp.gmail.com
port 587
from $gmail
user $gmail
password yourpasswd #yourpasswd改成你的gmail密码
account default : $USERNAME
第四部分getmail配置,这里使用pop3收信(要确认gmail打开此功能),七楼有修改,使用imap收信,procmail分拣邮件
vim ~/.getmail/getmailrc并写入如下代码
[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
port = 995
username = $gmail
password = yourpasswd #yourpasswd 这里改成你的密码
#
[destination]
type = Maildir
path = ~/Mail/inbox/
#
[options]
verbose = 0
delete = true
message_log = ~/.getmail/getmail.log
第五,别忘了,修改文件权限
chmod 600 ~/.muttrc ~/.getmail/getmailrc /etc/msmtprc |
|