为何无法从本机调用远端的postfix服务器发送邮件?

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
whaha
帖子: 99
注册时间: 2016-07-08 17:43
系统: debian8
送出感谢: 12 次
接收感谢: 0

为何无法从本机调用远端的postfix服务器发送邮件?

#1

帖子 whaha » 2017-10-07 20:32

a :代表本地端,我的本地电脑,域名 localhost.localdomain
b is 我的vps ,搭建了一个 postfix
c is 我的yahoo 邮箱。

登录b(我的vps)后,
我可以用下面的命令发送邮件到yahoo邮箱。
echo "test"|mail -s "test" account-in-yahoo@yahoo.com

这个是b(我的vps)上面的设置。

postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
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
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = domain.com
myhostname = mail.domain.com
mynetworks = 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550

下面,我想从本地端,调用b(我的vps) ,发送邮件到yahoo邮箱。

a(本地端)安装了msmtp.
cat .msmtprc

account default
host domain.com
user root
from root@mydomain.com
password xxxxxx
auth login
tls off
logfile .msmtp.log

在a(本地端)运行下面的命令
echo "test" | mail -v -s "test" xxxx@yahoo.com
cat /var/log/mail.log
Oct 7 08:09:50 localhost postfix/pickup[23565]: D6FA3482226: uid=1000 from=<root>
Oct 7 08:09:50 localhost postfix/cleanup[25879]: D6FA3482226: message-id=<20171007120950.D6FA3482226@localhost.localdomain>
Oct 7 08:09:50 localhost postfix/qmgr[4739]: D6FA3482226: from=<root@localdomain.localdomain>, size=359, nrcpt=1 (queue active)
Oct 7 08:09:55 localhost postfix/smtp[25881]: D6FA3482226: to=<xxxx@yahoo.com>, relay=mta5.am0.yahoodns.net[98.136.216.26]:25, delay=4.3, delays=0.08/0/2.5/1.8, dsn=2.0.0, status=sent (250 ok dirdel)
Oct 7 08:09:55 localhost postfix/cleanup[25879]: 38BC7482228: message-id=<20171007120955.38BC7482228@localhost.localdomain>
Oct 7 08:09:55 localhost postfix/bounce[26007]: D6FA3482226: sender delivery status notification: 38BC7482228
Oct 7 08:09:55 localhost postfix/qmgr[4739]: 38BC7482228: from=<>, size=1988, nrcpt=1 (queue active)
Oct 7 08:09:55 localhost postfix/qmgr[4739]: D6FA3482226: removed
Oct 7 08:09:55 localhost postfix/smtp[26008]: 38BC7482228: to=<root@localdomain.localdomain>, relay=none, delay=0.05, delays=0.03/0.01/0.01/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=localdomain.localdomain type=AAAA: Host not found)
Oct 7 08:09:55 localhost postfix/qmgr[4739]: 38BC7482228: removed

请问,为何无法在本地的电脑上调用我vps上的postfix ,发送邮件到yahoo邮箱?
b(vps)上的/etc/postfix/main.cf设置有问题?
mynetworks = 127.0.0.0/8
这里吗?还是哪里?
如何改?
头像
astolia
论坛版主
帖子: 3144
注册时间: 2008-09-18 13:11
送出感谢: 1 次
接收感谢: 527 次

Re: 为何无法从本机调用远端的postfix服务器发送邮件?

#2

帖子 astolia » 2017-10-10 21:36

现在正常的邮件服务器,为了防止垃圾邮件,都会对发件人的域名进行检查,你这个很显然就是检查没通过,postfix找不到localdomain.localdomain这个域名
Oct 7 08:09:55 localhost postfix/smtp[26008]: 38BC7482228: to=<root@localdomain.localdomain>, relay=none, delay=0.05, delays=0.03/0.01/0.01/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=localdomain.localdomain type=AAAA: Host not found)

即使你改了postfix,yahoo一样会检查,照样过不了
推荐阅读: http://lomu.me/post/SPF-DKIM-DMARC-PTR 以及它的前篇
回复

回到 “服务器基础应用”