Linux email邮件服务器配置(postfix)
测试系统:64位RHEL6
使用postfix配置MTA
一、安装包
postfix-2.6.6-2.el6.x86_64.rpm
二、配置文件(/etc/postfix/main.cf)【把有中文解释的配置项配置好或添加上就完成了基本的邮件服务配置,需要更多功能可继续添加配置】
#soft_bounce = no
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
#default_privs = nobody
myhostname = mail.example.com #设置邮件服务器主机名,不指定则用本机主机名
mydomain = example.com #设置邮件服务器的领域范围,不使用则使用本机的主机名的DNS后缀
myorigin = $mydomain #指定发送邮件时所用的DNS后缀
inet_interfaces = all #设置所有网络接口都监听SMTP请求
inet_protocols = all #设置所有协议均可监听
#proxy_interfaces =
#proxy_interfaces = 1.2.3.4
mydestination = $mydomain #指定邮件服务器允许处理发往当前域的所有邮件
#local_recipient_maps = unix:passwd.byname $alias_maps
#local_recipient_maps = proxy:unix:passwd.byname $alias_maps
#local_recipient_maps =
unknown_local_recipient_reject_code = 550
mynetworks_style = subnet #设置客户端IP地址使用子网匹配模式,与mynetworks子网IP匹配
mynetworks = 192.168.0.0/24 #设置客户端网段,指定这些网段里的邮件可直接将要发往外域的邮件提交给postfix
relay_domains = $mydomain #设置postfix是哪个区域的备件MTA(邮件传输代理)
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
#relay_recipient_maps = hash:/etc/postfix/relay_recipients
#in_flow_delay = 1s
#alias_maps = dbm:/etc/aliases
alias_maps = hash:/etc/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
alias_database = hash:/etc/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
#recipient_delimiter = +
#设定参数把邮件保存地点修改为每个用户家目录下指定的目录
#home_mailbox = Mailbox
#home_mailbox = Maildir/
#下面的是指定邮件保存路径
#mail_spool_directory = /var/mail
#mail_spool_directory = /var/spool/mail
#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a "$EXTENSION"
#mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
# mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#
# The efficiency of LMTP delivery for cyrus-imapd can be enhanced via
# these settings.
#
# local_destination_recipient_limit = 300
# local_destination_concurrency_limit = 5
#mailbox_transport = cyrus
#fallback_transport = lmtp:unix:/var/lib/imap/socket/lmtp
#fallback_transport =
#luser_relay = $user@other.host
#luser_relay = $local@other.host
#luser_relay = admin+$local
#header_checks = regexp:/etc/postfix/header_checks
#fast_flush_domains = $relay_domains
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
#local_destination_concurrency_limit = 2
#default_destination_concurrency_limit = 20
debug_peer_level = 2
#debug_peer_list = 127.0.0.1
#debug_peer_list = some.domain
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
# debugger_command =
# PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont;
# echo where) | gdb $daemon_directory/$process_name $process_id 2>&1
# >$config_directory/$process_name.$process_id.log & sleep 5
# debugger_command =
# PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen
# -dmS $process_name gdb $daemon_directory/$process_name
# $process_id & sleep 1
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
基本配置完成。
---------------------------------------------------------------------------------------------------------------------------
三、启动postfix服务
[root@linux115 postfix]# service postfix start
启动 postfix: [确定]
[root@linux115 postfix]# ps aux | grep postfix
root 16972 0.1 0.1 61972 2680 ? Ss 08:57 0:00 /usr/libexec/postfix/master
postfix 16974 0.0 0.1 62052 2592 ? S 08:57 0:00 pickup -l -t fifo -u
postfix 16975 0.0 0.1 62120 2636 ? S 08:57 0:00 qmgr -l -t fifo -u
root 16978 0.0 0.0 103164 816 pts/0 S+ 08:58 0:00 grep postfix
[root@linux115 postfix]#
----------------------------------------------------------------------------------------------------------------------
四、查看邮箱命令使用(mail)
直接使用mail可显示当前用户的邮件列表:
[root@linux115 postfix]# mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/root": 15 messages 2 unread
1 Anacron Sun May 27 09:06 23/984 "Anacron job 'cron.daily' on linux11"
2 Anacron Sun May 27 09:06 23/984 "Anacron job 'cron.daily' on linux11"
3 Anacron Sun May 27 09:06 23/984 "Anacron job 'cron.daily' on linux11"
4 Anacron Sun May 27 09:06 23/984 "Anacron job 'cron.daily' on linux11"
5 Anacron Sun May 27 09:06 23/984 "Anacron job 'cron.daily' on linux11"
>U 6 student Mon May 28 08:57 19/598 "hello"
7 root Mon May 28 08:57 19/553 "test"
8 root Mon May 28 09:00 20/562 "test2"
9 zglin Wed Jun 13 22:14 79/2799 "Re:888888"
10 Mail Delivery System Wed Jun 13 22:16 77/2535 "Undelivered Mail Returned to Sender"
11 zglin Wed Jun 13 22:17 52/2165 "hello,who are you?"
12 student3@zgl.gdupt.e Sun Jun 17 22:54 17/644 "*** SECURITY information for linux1"
U 13 student3@zgl.gdupt.e Sun Jun 17 22:57 17/643 "*** SECURITY information for linux1"
U 14 student3@zgl.gdupt.e Sun Jun 17 22:58 17/643 "*** SECURITY information for linux1"
15 zglin Mon Jul 16 10:28 66/2508 "Re:acb"
&
在最后的& 后可以输入其他命令对邮件列表中的邮件进行操作:
1)h 重新显示邮件列表
2)f * 指向某一个邮件
3)unread 将指定邮件标记为未读邮件
4)n * 阅读指定邮件
5)d * 删除指定邮件 也可以使用 "d 1-8" 进行批量删除
6)v * 编辑指定邮件
7)top * 显示指定邮件的邮件头(如果不指定则显示当前指针所在的邮件头)
8)q 退出mail命令,保存之前所有的操作,比如删除邮件
9)x 退出mail命令,不保存之前所有的操作,比如删除邮件
--------------------------------------------------------------------------------------------------------------------------------
五、使用mail命令发邮件
[root@linux115 postfix]# mail mmcwho@163.com
Subject: hello!Nice to meet you! #邮件标题
hello,i am linux11. #邮件正文内容
. #在空白行输入“.”按Enter发送邮件并退出,可使用Ctrl+c中断邮件操作不发送并退出
EOT
[root@linux115 postfix]#
#上面配置的只是基本的邮件服务,还邮件管理、邮件安全、垃圾过滤等更多内容可学习配置。
更多推荐
所有评论(0)