所以,我想从我的服务器发送电子邮件。
我安装了 mailx
apt-get install mailx
Run Code Online (Sandbox Code Playgroud)
但是像这样的命令
mail -s "Hello world" me@gmail.com
Run Code Online (Sandbox Code Playgroud)
实际上在/var/spool/mail/ 中给出了一个错误,它说:
Mailing to remote domains not supported.
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
vmf*_*rms 18
您在本地使用什么 MTA?mail只是给了你形成邮件消息的能力,但你仍然需要和 MTA 来做实际的传递?默认情况下,大多数发行版都带有 sendmail。您可能需要安装另一个 MTA 或配置当前的 MTA 以支持外部交付。
Run Code Online (Sandbox Code Playgroud)# fgrep remote /var/log/exim4/mainlog.1 | sed -E 's#([ <])[^ <]+@[^ >]+([ >])#\1a@b\2#g' | head -1 2019-01-08 00:47:00 1ggebk-00055M-St ** a@b <a@b> R=nonlocal: Mailing to remote domains not supported #
看起来 Debian 可能带有一个exim4设置为无法在连接 Internet 的机器上正常工作的机器,其中传出的 smtp 端口没有被阻止。
正如各种评论中所指出的,要使其正常工作,必须运行dpkg-reconfigure exim4-config,并在向导中选择第一个internet选项。请注意,在向导中的后续对话框中,默认值仍设置为仅侦听localhostIPv4/IPv6 地址,因此,如果您不理会其他默认值,则似乎仍不理会传入的 SMTP 端口。
要验证向导是否正常工作,您可以检查特定于 Debian 的/etc/exim4/update-exim4.conf.conf(是的,它是一个 double .conf.conf,这不是错字),它在这场惨败中发挥了作用。这是运行后的相关部分dpkg-reconfigure exim4-config,仅更改向导中的第一个选项,该选项允许发送邮件,但保持 SMTP 端口仅对机器本身开放(如果您在第一个选项后单击重新配置,则为默认选项) :
dc_eximconfig_configtype='internet'
…
dc_local_interfaces='127.0.0.1 ; ::1'
Run Code Online (Sandbox Code Playgroud)
另一种解决方案是在 jessie 及更高版本中安装DragonFly Mail Agent — https://packages.debian.org/jessie/dma — 这是 MTA 的一个简单实现,实现了除传入 SMTP 之外的所有好的 UNIX 邮件内容,所以,您不必担心配置错误或外部漏洞。
| 归档时间: |
|
| 查看次数: |
24776 次 |
| 最近记录: |