Postfix 邮件发送功能配置

Mail Postfix 邮件发送功能配置

博主: haitianisgood
原博客网址:
https://mp.csdn.net/mdeditor/81984376

环境

Centos

安装postfix

默认centos 安装了postfix,使用默认的即可

yum -y install postfix

配置postfix

实现使用postfix来发送邮件

配置如下:

grep -v '^#' /etc/postfix/main.cf | grep -v '^$' 输出结果:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.haitian.com
mydomain = haitian.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = haitian.com,$myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 172.16.0.0/16,172.16.0.0/8,172.16.89.0/24,127.0.0.0/8
relay_domains = $mydestination, $mynetworks
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/


debug_peer_level = 2
debugger_command =
   PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
   ddd $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.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

配置客户端服务器

在需要使用postfix发送邮件的服务器/etc/hosts中或在私有DNS中添加以下记录:

10.0.3.3 mail.haitian.com

测试邮件发送

简单测试

在Postfix服务器上执行命令:

echo "mail content" |mail -s test [email protected]

测试结果:

[email protected]此邮件地址收到mail content内容的邮件

postfix日志:

postfix/pickup[15143]: 66D362604EA: uid=0 from=
postfix/cleanup[15483]: 66D362604EA: message-id=<[email protected]>
postfix/qmgr[15144]: 66D362604EA: from=, size=434, nrcpt=1 (queue active)
postfix/smtp[15487]: 66D362604EA: to=, relay=cdn11.intel-email.com[222.73.227.238]:25, delay=4.5, delays=0.11/0.03/3.4/0.97, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 7CED62B991A04)
postfix/qmgr[15144]: 66D362604EA: removed

表示已经正常发送

最后去[email protected]邮箱去查看是否已经接收到邮件,没有收到很可能被邮箱自己屏蔽了,将mail.haitian.com加入白名单。

你可能感兴趣的:(Linux)