sendmail中如果非root用户想实现邮件转发功能,可以通过.forward文件来实现,这个文件是放在用户主目录下的
如用户peter的主目录是/home/peter
[peter@station11 ~]$ cat /home/peter/.forward
test
\peter
[peter@station11 ~]$
如果邮件的转发同时要转发给本身一份,则需要在用户名前添加一个\代表取消转发,免得无限循环下去呵!
清空maillog记录
[root@station11 ~]# > /var/log/maillog
发测试邮件
[root@station11 ~]# ls -l | mail -s "test .forward file function " peter@station11.example.com
检查mail的log信息
[root@station11 ~]# cat /var/log/maillog
Jan 2 14:10:42 station11 sendmail[26665]: o02MAg5a026665: from=root, size=303, class=0, nrcpts=1, msgid=<201001022210.o02MAg5a026665@station11.example.com>, relay=root@localhost
Jan 2 14:10:42 station11 sendmail[26666]: o02MAgIw026666: from=<root@station11.example.com>, size=609, class=0, nrcpts=1, msgid=<201001022210.o02MAg5a026665@station11.example.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Jan 2 14:10:42 station11 sendmail[26665]: o02MAg5a026665: to=peter@station11.example.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30303, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o02MAgIw026666 Message accepted for delivery)
Jan 2 14:10:42 station11 sendmail[26667]: o02MAgIw026666: to=test, ctladdr=<root@station11.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=60847, dsn=2.0.0, stat=Sent
Jan 2 14:10:42 station11 sendmail[26667]: o02MAgIw026666: to=\\peter, ctladdr=<root@station11.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=60847, dsn=2.0.0, stat=Sent
[root@station11 ~]#
看maillog日志格式:
时间戳++++++++主机名(这里是station11)++++++++服务器软件名++++to=发送给谁++++ctladdr=谁发的邮件stat=Send说明邮件已发送出去,但不保证对端收到呵,但能说明本端服务配置基本是正常的
还有一种方法是查mailq,mailq显示出站邮件队列,如果 报告队列中有消息则说明本地或者远程配置或者网络有问题呵!自己给自己发邮件则说明本地配置有问题了
[root@station11 mqueue]# mailq
/var/spool/mqueue is empty
Total requests: 0
这时要说明的是一个权限问题,.forward文件只允许属主有写权限,其他不能有写要限
[root@station11 ~]# ls /home/peter/.forward -l
-rwxrwxr-x 1 peter peter 12 Jan 1 15:06 /home/peter/.forward
[root@station11 ~]# > /var/log/maillog
[root@station11 ~]# ls -l | mail -s "test .forward permission " peter
[root@station11 ~]# mailq
/var/spool/mqueue is empty
Total requests: 0
[root@station11 ~]# su - test
[test@station11 ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/test": 2 messages 1 new 2 unread
U 1 root@station11.examp Fri Jan 1 15:22 20/722 "test ls command 2"
>N 2 root@station11.examp Sat Jan 2 14:10 20/921 "test .forward file function"
& q
Held 2 messages in /var/spool/mail/test
[test@station11 ~]$ su - peter
Password:
[peter@station11 ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/peter": 3 messages 2 new 3 unread
U 1 root@station11.examp Fri Jan 1 15:06 20/722 "test ls command 1"
>N 2 root@station11.examp Sat Jan 2 14:10 20/921 "test .forward file function"
N 3 root@station11.examp Sat Jan 2 14:36 20/896 "test .forward permission"
& q
Held 3 messages in /var/spool/mail/peter
[peter@station11 ~]$ exit
logout
[test@station11 ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/test": 2 messages 2 unread
>U 1 root@station11.examp Fri Jan 1 15:22 20/722 "test ls command 2"
U 2 root@station11.examp Sat Jan 2 14:10 21/931 "test .forward file function"
& q
Held 2 messages in /var/spool/mail/test
[test@station11 ~]$ exit
logout
[root@station11 ~]# cat /var/log/maillog
Jan 2 14:36:05 station11 sendmail[27438]: o02Ma5sj027438: from=root, size=278, class=0, nrcpts=1, msgid=<201001022236.o02Ma5sj027438@station11.example.com>, relay=root@localhost
Jan 2 14:36:05 station11 sendmail[27439]: o02Ma5SB027439: from=<root@station11.example.com>, size=584, class=0, nrcpts=1, msgid=<201001022236.o02Ma5sj027438@station11.example.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Jan 2 14:36:05 station11 sendmail[27440]: o02Ma5SB027439: forward /home/peter/.forward: Group writable file <===test用户收不到邮件的原因在这里
Jan 2 14:36:05 station11 sendmail[27438]: o02Ma5sj027438: to=peter, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30278, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o02Ma5SB027439 Message accepted for delivery)
Jan 2 14:36:05 station11 sendmail[27440]: o02Ma5SB027439: to=<peter@station11.example.com>, ctladdr=<root@station11.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30822, dsn=2.0.0, stat=Sent
[root@station11 ~]#
下面是更新了权限后,test用户很书就收到邮件,注意邮件标题呵!
[root@station11 ~]# chmod 700 /home/peter/.forward
[root@station11 ~]#
[root@station11 ~]#
[root@station11 ~]#
[root@station11 ~]# > /var/log/maillog
[root@station11 ~]# ls -l | mail -s "test .forward permission XXXXXXXXXXXXXX " peter
[root@station11 ~]# su - test
[test@station11 ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/test": 3 messages 1 new 3 unread
U 1 root@station11.examp Fri Jan 1 15:22 20/722 "test ls command 2"
U 2 root@station11.examp Sat Jan 2 14:10 21/931 "test .forward file function"
>N 3 root@station11.examp Sat Jan 2 14:38 20/911 "test .forward permission XXXXXXXXXXXXXX"
& q
Held 3 messages in /var/spool/mail/test
[test@station11 ~]$
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |