postfix实现邮件发送的简单配置


postfix实现邮件发送的简单配置
 
1安装postfix。
 
使用 rpm –qa postfix检查是否安装了postfix,如果没有,使用yum install postfix。
 
2 配置/etc/postfix/main.cf
 
 [root@reage ~]# vim /etc/postfix/main.cf ←编辑Postfix的配置文件
 
#myhostname = host.domain.tld ←找到此行,将等号后面的部分改写为主机名
myhostname = smtp.rhttp.cn ←变为此状态,设置系统的主机名
 
#mydomain = domain.tld ←找到此行,将等号后面的部分改写为域名
mydomain = rhttp.com ←变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)
 
#myorigin = $mydomain ←找到此行,将行首的#去掉
myorigin = $mydomain ←变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)
 
inet_interfaces = localhost ←找到此行,将“localhost”改为“all”
inet_interfaces = all ←变为此状态,接受来自所有网络的请求
 
mydestination = $myhostname, localhost.$mydomain, localhost ←找到此行,在行为添加“$mydomain”
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ←变为此状态,指定发给本地邮件的域名
 
#relay_domains = $mydestination ←找到此行,将行首的#去掉
relay_domains = $mydestination ←变为此状态,定义允许转发的域名
 
#mynetworks = 168.100.189.0/28, 127.0.0.0/8 ←找到此行,依照自己的内网情况修改
mynetworks = 168.100.189.0/28, 127.0.0.0/8 ←变为此状态,指定内网和本地的IP地址范围
 
#home_mailbox = Maildir/ ←找到这一行,去掉行首的#
home_mailbox = Maildir/ ←变为此状态,指定用户邮箱目录
 
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) ←找到这一行,接此行添加如下行:
smtpd_banner = $myhostname ESMTP unknow ←添加这一行,不显示SMTP服务器的相关信息
 
在配置文件的文尾,添加如下行:
 
smtpd_sasl_auth_enable = yes ←服务器使用SMTP认证
smtpd_sasl_local_domain = $myhostname ←指定SMTP认证的本地域名(主机名)
smtpd_sasl_security_options = noanonymous  ←不允许匿名的方式认证
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination 
message_size_limit = 15728640 ←规定邮件最大尺寸为15MB
 
 
3 配置SMTP认证的相关选项
 
  为了提高安全性,我们不将系统用户的密码作为相应用户SMTP认证的密码,而将在后面为用户建立SMTP认证专用的密码。
 
/etc/sasl2/smtpd.conf
 
[root@reage ~]# vim /usr/sasl2/smtpd.conf ←编辑SMTP认证的配置文件
 
pwcheck_method: saslauthd ←找到此行,将“saslauthd”改为“auxprop”
pwcheck_method: auxprop ←不使用系统用户密码作为用户的SMTP认证密码
 
[root@reage ~]# vim /etc/sysconfig/saslauthd
 
MECH=shadow ← 找到这一行,在前面加# 
#MECH=shadow ←不使用shadow机制
 
FLAGS= ← 找到此行,在等号后面添加“sasldb”
FLAGS=sasldb  ←定义认证方式为sasldb2
 
4  为用户设置密码
 
saslpasswd2 –u myhostname -cuserid
 
将集中的myhostname换成在main.cf中myhostname值。
 
Userid是你要设置密码的用户
 
例如我对reage的密码进行设置
 
[root@reage ~] saslpasswd2 –usmtp.rhttp.ch -c reage
 
Password:
 
Again ( for verification):
 
[root@reage ~]

相关内容

    暂无相关文章