postfix架设smtp用来发邮件

发布时间:2019-09-22编辑:脚本学堂
本文介绍了postfix邮件服务喊叫的架设方法,使用postfix架设smtp发送邮件的步骤详解,有需要的朋友参考下。

本节内容:
使用postfix架设smtp,仅用于发邮件

系统环境:
centos 5.3 x64

1.安装postfix软件和cyrus-sasl软件
 

复制代码 代码示例:
yum -y install postfix cyrus-sasl-*

2.修改postfix的配置文件
 

复制代码 代码示例:
mv /etc/postfix/main.cf /etc/postfix/main.cf.bak
vi /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = mail.test.com.cn
mydomain = test.com.cn
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.100.0/24,192.168.0.0/24,127.0.0.0/8
relay_domains = $mydestination
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = maildir/
smtpd_banner = $myhostname esmtp unknow
debug_peer_level = 2
debugger_command =
         path=/bin:/usr/bin:/usr/local/bin:/usr/x11r6/bin
         xxgdb $daemon_directory/$process_name $process_id & sleep 5
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.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/readme_files
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 15728640

3.修改或者创建sasl的配置文件
 

复制代码 代码示例:
vi /usr/lib64/sasl2/smtpd.conf
  pwcheck_method: auxprop
  vi /etc/sysconfig/saslauthd
  mech=pam ----> #mech=pam
  flags= ------> flags=sasldb

4.添加用户名和密码
 

复制代码 代码示例:
saslpasswd2 -u `postconf -h myhostname` -c username
 

  输入两次密码

注意,如果需要通过telnet方式来验证用户名和密码是否能成功登陆的时候,在使用perl -mmime::base64 -e 'print encode_base64("username or password")'
  中的username需要加上myhostname,例如你的myhostname为mail.test.com.cn 那么用户名就应该为username@mail.test.com,特别需要注意的是在@前面需要加上“”不然验证是会失败的.

5.启动postfix服务