电子邮件 – Sendmail和nslookup解决问题

前端之家收集整理的这篇文章主要介绍了电子邮件 – Sendmail和nslookup解决问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的ubuntu服务器上,我一直试图通过安装sendmail来使 PHP mail()函数工作(我也安装了postfix但我放弃了它).但是,当我尝试发送邮件时,它会在/var/log/mail.log中排队并出现以下错误
sm-mta[xxx]: gethostbyaddr(x.x.x.x) Failed: x

当我执行nslookup(例如nslookup gmail.com)时,它说它无法解决并且连接超时.在花了一整天的时间并尝试各种各样的事情后,我决定将我的域名服务器放入我的interfaces文件中,按照:https://askubuntu.com/a/331636

这减轻了我使用nslookup时出现的问题,但在尝试发送邮件时,我仍然在日志中收到相同的错误,除了我的公共IP地址没有显示,只有私有IP地址.例如

sm-mta[xxx]: gethostbyaddr(178.x.x.x) Failed: x # public IP error not showing anymore
sm-mta[xxx]: gethostbyaddr(10.x.x.x) Failed: x # private IP error still showing

我已经看了很多关于这方面的文档,我仍然不确定我做错了什么.我已经检查过sendmail正在使用端口25.由于我只发送邮件,我是否需要担心我的服务器有关MX的DNS记录?

在/etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8

/etc/dhcp/dhclient.conf:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

#send host-name "andare.fugue.com";
send host-name = gethostname();
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask,broadcast-address,time-offset,routers,domain-name,domain-name-servers,domain-search,host-name,dhcp6.name-servers,dhcp6.domain-search,netbios-name-servers,netbios-scope,interface-mtu,rfc3442-classless-static-routes,ntp-servers,dhcp6.fqdn,dhcp6.sntp-servers;
#require subnet-mask,domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2","link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}

etc / hosts文件

# Your system has configured 'manage_etc_hosts' as True.
# As a result,if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
127.0.1.1 domain.name
127.0.0.1 localhost.localdomain localhost
178.x.x.x domain.name

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

解决方法

据我所见,您只想发送邮件.在这种情况下,您不能为服务器设置MX记录,因为您的邮件服务器不对任何域负责.

如果我理解你的问题,你真的只想要一个MTA来传递你的邮件.

为此目的设置一个完整的邮件服务器是过度的;所以首先这里有几个选择:
https://unix.stackexchange.com/questions/1449/lightweight-outgoing-smtp-server

如果你想要一个真正的邮件服务器,postfix将是更好的:
https://askubuntu.com/questions/457003/setting-up-a-send-only-mail-server

但是,您的DNS问题可能与此无关.

当然,可以解决服务器上使用的所有IP和主机名.要实现此目的,您需要一个本地名称服务器,用于本地地址(和名称),以便将任何其他请求转发给其他名称服务器.

但可能有一种更简单的方法邮件服务器执行的DNS查找应取决于邮件发件人和收件人域.你应该检查,如果这些是正确的,只是限制自己的名称,可以解决.也许您已将From-address配置为指向某个本地定义的域?

要对此进行调试,您可以先尝试从命令行发送邮件,然后尽快转到PHP邮件程序.

来自队列的示例邮件将有助于检查这一点.

你能否发布一下你的输出
netstat -natp

只是为了看看sendmail绑定的IP地址.

我知道这个答案并不完整,但这就是我现在可以说的.

猜你在找的HTML相关文章