Msmtp发送失败邮件的处理方法

在安装包中: /msmtp-1.4.28/scripts/msmtpqueue目录下有如下文件:

[root@hunt1574 msmtpqueue]# ls -l

总计 20

-rw-r--r-- 1 1000 1000 1084 05-01 23:58 ChangeLog

-rwxr--r-- 1 1000 1000 1078 05-01 23:58 msmtp-enqueue.sh

-rwxr--r-- 1 1000 1000 175 05-01 23:58 msmtp-listqueue.sh

-rwxr--r-- 1 1000 1000 1228 05-01 23:58 msmtp-runqueue.sh

-rw-r--r-- 1 1000 1000 2586 05-01 23:58 README

三个文件的作用如下:

1. msmtp-enqueue.sh

Let your MUA "send" mails with this script.

It will store all mails in a queue directory for later delivery.

This script will save two files for each mail: one contains the mail, the

other one contains the command line for msmtp (including options and the

recipients). Thus you can use all msmtp options with this script.

Example (using Mutt):

In your Mutt configuration file, replace

set sendmail="/path/to/msmtp [options]"

with

set sendmail="/path/to/msmtp-enqueue.sh [options]"

This script cannot detect errors in its command line or the msmtp

configuration file. You won't see error messages before msmtp-runqueue.sh

runs msmtp to send the mails. So test your msmtp configuration before using

msmtp-enqueue.sh.

2. msmtp-runqueue.sh

Run this script when you are online to send all mails in the queue

directory.

It will use the saved msmtp command line for each mail.

Mails sent successfully will be deleted from the queue directory.

Mails whose delivery failed will be left untouched; you may want to edit

them, delete them by hand or simply run msmtp-runqueue.sh at a later time.

3. msmtp-listqueue.sh

This script lists all the mails in the queue.

参考的文章(http://zoomquiet.org/res/scrapbook/ZqFLOSS/data/20110506155957/)说安装后会在/usr/share/doc/msmtp/examples中包含以上文件,安装两遍没有找到该目录,手动创建目录并将/msmtp-1.4.28/scripts/msmtpqueue中的内容复制到/usr/share/doc/msmtp/examples中(放到原来目录也可)。

[root@hunt1574 examples]# ls -l

总计 20

-rw-r--r-- 1 root root 1084 05-12 10:05 ChangeLog

-rwxr-xr-x 1 root root 1078 05-12 10:05 msmtp-enqueue.sh

-rwxr-xr-x 1 root root 175 05-12 10:05 msmtp-listqueue.sh

-rwxr-xr-x 1 root root 1228 05-12 10:05 msmtp-runqueue.sh

-rw-r--r-- 1 root root 2586 05-12 10:05 README

[root@hunt1574 examples]# pwd

/usr/share/doc/msmtp/examples

在当前用户创建.mutt目录,将/usr/share/doc/msmtp/examples的链接指向.mutt。

[root@hunt1574 examples]# ln -s /usr/share/doc/msmtp/examples/* ~/.mutt

[root@hunt1574 ~]# ls .mutt

ChangeLog msmtp-enqueue.sh msmtp-listqueue.sh msmtp-runqueue.sh EADME

修改.muttrc:

[root@hunt1574 ~]# cat .muttrc

#set sendmail="/usr/local/bin/msmtp"

set sendmail="~/.mutt/msmtp-enqueue.sh" ----修改后的内容

set use_from=yes

set from="hunt1574<[email protected]>"

set envelope_from=yes

set sendmail_wait=0

测试:

[root@hunt1574 ~]# cat .muttrc | mutt -s "Muttrc configfile" [email protected]

---发送一份邮件给[email protected],此时邮件进行队列,并未发送出去。

[root@hunt1574 ~]# cd .msmtpqueue/

[root@hunt1574 .msmtpqueue]# ll

总计 8

-rw------- 1 root root 476 05-12 10:53 2012-05-12-10.53.02.mail

-rw------- 1 root root 46 05-12 10:53 2012-05-12-10.53.02.msmtp

[root@hunt1574 .msmtpqueue]# cat 2012-05-12-10.53.02.mail

---此文件包含了邮件内容,可直接更改

Date: Sat, 12 May 2012 10:53:02 +0800

From: hunt1574 <[email protected]>

To: [email protected]

Subject: Muttrc configfile

Message-ID: <[email protected]>

Mime-Version: 1.0

Content-Type: text/plain; charset=us-ascii

Content-Disposition: inline

User-Agent: Mutt/1.4.2.2i

#set sendmail="/usr/local/bin/msmtp"

set sendmail="~/.mutt/msmtp-enqueue.sh"

set use_from=yes

set from="hunt1574<[email protected]>"

set envelope_from=yes

set sendmail_wait=0

[root@hunt1574 .msmtpqueue]# cat 2012-05-12-10.53.02.msmtp

----此文件包含了发送的参数,可直接更改

-f [email protected] -- [email protected]

[root@hunt1574 .msmtpqueue]# cd ../.mutt

[root@hunt1574 .mutt]# ./msmtp-listqueue.sh

---邮件的发送队列

From: hunt1574 [email protected]

---此处hunt1574如果是中文会显示乱码

To: [email protected]

Subject: Muttrc configfile

[root@hunt1574 .mutt]# ./msmtp-runqueue.sh

*** Sending 2012-05-12-10.53.02.mail to [email protected] ...

2012-05-12-10.53.02.mail sent successfully

*** Sending 2012-05-12-11.00.27.mail to [email protected] ...

2012-05-12-11.00.27.mail sent successfully

*** Sending 2012-05-12-11.00.37.mail to [email protected] ...

2012-05-12-11.00.37.mail sent successfully

---显示发送成功

登录邮箱查看:

clip_image0024_thumb

clip_image0044_thumb

另外,登录邮箱发邮件的做法网上类似这样的:

修改/etc/mail.rc,加入以下内容:

set [email protected]

set smtp=smtp.test.com

set smtp-auth=login

set smtp-auth-user=hunt1574

set smtp-auth-password=123456

在RHEL5.4 及RHEL4.5均未通过,总是连接本地127.0.0.1,若有成功的肯请赐教,邮箱:[email protected]

测试结果1:

clip_image006_thumb

测试结果2:

clip_image008_thumb

你可能感兴趣的:(邮件,face)