一,安装:
[root@station10 ~]# yum install -y sendmail* [root@station10 ~]# rpm -aq | grep sendmail sendmail-doc-8.13.8-2.el5 sendmail-cf-8.13.8-2.el5 sendmail-devel-8.13.8-2.el5 sendmail-8.13.8-2.el5 [root@station10 ~]# 二,sendmail进入的配置 1,修改 /etc/mail/sendmail.mc 文件,让监听所有网卡地址,在前面加上dnl # 即可: [root@station10 mail]# vi sendmail.mc dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl 2,修改 /etc/mail/local-host-names 文件。 [root@station10 mail]# cat local-host-names # local-host-names - include all aliases for your machine here. station10.example.com [root@station10 mail]# 3,重启 sendmail [root@station10 mail]# service sendmail restart Shutting down sendmail: [FAILED] Starting sendmail: [ OK ] Starting sm-client: [ OK ] [root@station10 mail]# 4,查看监听的端口: [root@station10 ~]# netstat -tulpn | grep sendmail tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1094/sendmail: acce [root@station10 ~]# 5,测试 [root@station10 ~]# mail -v root Subject: test mail test. . Cc: root... Connecting to [127.0.0.1] via relay... 220 station10.example.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 21 Oct 2008 00:13:23 +0800 >>> EHLO station10.example.com 250-station10.example.com Hello localhost.localdomain [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-DELIVERBY 250 HELP >>> MAIL From:< [email protected]> SIZE=35 250 2.1.0 < [email protected]>... Sender ok >>> RCPT To:< [email protected]> >>> DATA 250 2.1.5 < [email protected]>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 250 2.0.0 m9KGDNiO001110 Message accepted for delivery root... Sent (m9KGDNiO001110 Message accepted for delivery) Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 station10.example.com closing connection [root@station10 ~]# 三,sendmail 出去的配置 1,umcomment the following linex in /etc/mail/sendmail.mc EXPOSED_USER(`root')dnl FEATURE(masquerade_envelope)dnl MASQUERADE_AS('station10.example.com')dnl FEATURE(masquerade_entire_domain)dnl 2,测试 [root@station10 ~]# mail -v [email protected] Subject: test from station10.example.com . Cc: [email protected]... Connecting to [127.0.0.1] via relay... 220 station10.example.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 21 Oct 2008 00:43:26 +0800 >>> EHLO station10.example.com 250-station10.example.com Hello localhost.localdomain [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-DELIVERBY 250 HELP >>> MAIL From:< [email protected]> SIZE=73 250 2.1.0 < [email protected]>... Sender ok >>> RCPT To:< [email protected]> >>> DATA 250 2.1.5 < [email protected]>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 250 2.0.0 m9KGhQAN001280 Message accepted for delivery [email protected]... Sent (m9KGhQAN001280 Message accepted for delivery) Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 station10.example.com closing connection [root@station10 ~]# 3,在其他机器上接收邮件 [root@station12 ~]# mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 [email protected] Tue Oct 21 07:56 19/905 "test" & 1 Message 1: From [email protected] Tue Oct 21 07:56:06 2008 Date: Tue, 21 Oct 2008 00:43:26 +0800 From: root < [email protected]> To: [email protected] Subject: test from station10.example.com & q Saved 1 message in mbox [root@station12 ~]# 四,进入的邮箱别名 1,本地别名配置:/etc/aliases [root@station10 mail]# vi /etc/aliases 新增: xxx: root xxx这个名字可以是不存在的用户,用户名后面记得加: 2,执行newaliases让配置生效。 [root@station10 ~]# newaliases /etc/aliases: 77 aliases, longest 10 bytes, 772 bytes total [root@station10 ~]# 3,测试 [root@station10 ~]# mail xxx Subject: test inbound send to xxx . Cc: [root@station10 ~]# mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 [email protected] Tue Oct 21 00:51 16/659 "test inbound" & 1 Message 1: From [email protected] Tue Oct 21 00:51:43 2008 Date: Tue, 21 Oct 2008 00:51:43 +0800 From: root < [email protected]> To: [email protected] Subject: test inbound send to xxx & q Saved 1 message in mbox [root@station10 ~]# 4,虚拟别名配置: 修改/etc/mail/virtusertable文件,增加下面一行: [email protected] [email protected] [root@station10 mail]# cat virtusertable [email protected] [email protected] [root@station10 mail]# 5,重启服务 [root@station10 mail]# service sendmail restart Shutting down sm-client: [ OK ] Shutting down sendmail: [ OK ] Starting sendmail: [ OK ] Starting sm-client: [ OK ] [root@station10 mail]# 6,测试: 发送到station10服务器中: [root@station10 mail]# mail [email protected] Subject: test inbound sendmail Aliases send to station10 . Cc: [root@station10 mail]# 在station12服务器中接收到数据: Saved 1 message in mbox [root@station12 ~]# mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 [email protected] Tue Oct 21 08:13 19/921 "test inbound sendmail" & 1 Message 1: From [email protected] Tue Oct 21 08:13:36 2008 Date: Tue, 21 Oct 2008 01:00:56 +0800 From: root < [email protected]> To: [email protected] Subject: test inbound sendmail Aliases send to station10 & q Saved 1 message in mbox [root@station12 ~]# 五,出去的地址重写 1,在/etc/mail/sendmail.mc中增加如下内容: FEATURE(genericstable)dnl FEATURE(`always_add_domain')dnl GENERICS_DOMAIN_FILE(`/etc/mail/local-host-names')dnl 例子,文件最后几行: dnl MASQUERADE_DOMAIN(mydomain.lan)dnl FEATURE(genericstable)dnl FEATURE(`always_add_domain')dnl GENERICS_DOMAIN_FILE(`/etc/mail/local-host-names')dnl MAILER(smtp)dnl MAILER(procmail)dnl dnl MAILER(cyrusv2)dnl 2,新增文件 /etc/mail/genericstable,并添加如下内容: [root@station10 mail]# cat /etc/mail/genericstable [email protected] [email protected] [email protected] [email protected] [root@station10 mail]# 3,重启服务 [root@station10 mail]# /etc/init.d/sendmail restart Shutting down sm-client: [ OK ] Shutting down sendmail: [ OK ] Starting sendmail: [ OK ] Starting sm-client: [ OK ] [root@station10 mail]# 4,测试: 发送邮件给station12.example.com [root@station10 ~]# mail [email protected] Subject: station10.example.com test . Cc: [root@station10 ~]# 查收接收到邮件: [root@station12 ~]# mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/root": 2 messages 2 new >N 1 [email protected] Tue Oct 21 11:14 69/2334 "Logwatch for station1" N 2 [email protected] Wed Oct 22 02:39 19/867 "station10.example.com" & 2 Message 2: From [email protected] Wed Oct 22 02:39:53 2008 Date: Tue, 21 Oct 2008 19:26:56 +0800 From: root < [email protected]> To: [email protected] Subject: station10.example.com test & q Saved 1 message in mbox Held 1 message in /var/spool/mail/root [root@station12 ~]# 六,垃圾邮件限制: 1,enable in /etc/mail/sendmail.mc using FEATURE('blacklist_recipients')dnl 2, add restrictions in /etc/mail/access From:[email protected] REJECT Connect:spamRus.net REJECT Connect:204.168.23 REJECT Connect:10.3 OK From:virtualdomain1.com RELAY to:[email protected] ERROR:550 mail discarded to:nobody@ ERROR:550 bad name 七,Sendmail Operation mail -v user view SMTP exchange with local relay mailq and mailq -Ac view messages queued for future delivery sendmail -q reprocess the email queue tail -f /var/log/maillog view log in real-time
八,安装POP3服务
需要安装QPopper
http://www.eudora.com/products/unsupported/qpopper/index.html qpopper4.0.8.tar.gz QPopper的安装配置 QPopper是Unix/Linux环境下的POP3服务器,该软件配合Sendmail使用。其主要功能是实现支持用户通过POP3接收信件。安装和配置Qpopper的主要步骤如下:
1.创建从/usr/mail指向/var/spool/mail/的链接(可以省掉)
[root@email src]# ln -s /var/spool/mail/ /usr/mail
2.解压QPopper软件包
[root@email src]# tar xvfz QPopper4.0.3.tar.gz [root@email src]# cd QPopper4.0.3
3.编译安装QPopper
[root@email QPopper4.0.3]# ./configure [root@email QPopper4.0.3]# make [root@email QPopper4.0.3]# make install
注意:安装时可能需要建立相应个文件夹
# mkdir -p /usr/local/man/man8 ******************* 编译需要GCC yum install gcc (安装GCC) yum install glibc yum install pam-devel (编译工具) yum install pam yum install inetd (安装inetd) *******************
编辑/etc/xinetd.d/popper
service pop3 { disable = no socket_type = stream protocol = tcp wait = no user = root server = /usr/local/sbin/popper server_args = -s port = 110 }
然后重新启动:
# service xinetd restart
查看端口情况
netstat –a (应该看到POP3 SMTP端口正常)
添加用户组:popmail
# groupadd popmail
添加用户
# useradd username -g popmail -s /sbin/nologin # passwd username |