如何设置(非常)简单的sendmail

kni*_*ter 5 email sendmail

我一直在尝试让命令行 sendmail 工作,但没有成功。我需要这个来在某处输出我的 anacron 错误。

我已经安装了 sendmail 包。配置 /etc/aliases 为:

root: me@gmail.com
Run Code Online (Sandbox Code Playgroud)

但是每当我尝试向任何地址(root,me@gmail.com)发送电子邮件时,sendmail 日志一直告诉我它已中继到“localhost”并已发送。再也找不到了。有些文件是在 /var/mail/mqueue 中创建的。

日志输出:

root@tok:/var/mail# sendmail me@gmail.com test37

Feb 27 13:35:40 tok sendmail[23616]: r1RCZanW023616: from=tys, size=7, class=0, nrcpts=1, msgid=<201302271235.r1RCZanW023616@tok.mydomain.nl>, relay=root@localhost
Feb 27 13:35:40 tok sm-mta[23617]: r1RCZe41023617: from=<tys@tok.mydomain.nl>, size=289, class=0, nrcpts=1, msgid=<201302271235.r1RCZanW023616@tok.mydomain.nl>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Feb 27 13:35:40 tok sendmail[23616]: r1RCZanW023616: to=me@gmail.com, ctladdr=tys (1000/1000), delay=00:00:04, xdelay=00:00:00, mailer=relay, pri=30007, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r1RCZe41023617 Message accepted for delivery)
Run Code Online (Sandbox Code Playgroud)

为什么它决定应将 me@gmail.com 传送到 localhost 并且它从未尝试实际连接到 gmail.com?

我应该如何配置它?我宁愿根本没有运行任何邮件服务器。我只希望该sendmail命令起作用并将我的本地根邮件转发到邮件地址。sendmail 不能只查找 rcpt 域的 MX 记录,然后将其传送到那里吗?

我还尝试将别名放在 /root/.forward 中,尝试转发到本地文件。都没有成功。我newaliases在编辑 /etc/aliases 之后跑了。我试过重新启动 init.d/sendmail。

小智 2

我相信您的邮件已排队。尝试mailq然后sendmail -qsendmail -q -v

也有可能,该电子邮件因未知主机而被保留。您需要设置localhosthostname进入/etc/hosts

您通常不需要使用sendmail命令行来发送电子邮件,因为它不太方便。你应该使用mailxmutt

mailx

echo you message  | mail -s subject user@host
Run Code Online (Sandbox Code Playgroud)