使用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 那么用户名就应该为,特别需要注意的是在@前面需要加上“\”不然验证是会失败的.
5.启动postfix服务
阅读(2728) | 评论(1) | 转发(0) |