我正在尝试使用以下 bash 脚本发送电子邮件:
/bin/mail -s "#subject" "$emailto" < "$message"
它在我的本地计算机上运行良好,但在我的虚拟机上不起作用。我查了一下,发现问题可能与该/etc/hosts
文件有关,所以这是该文件的内容:
127.0.0.1 localhost loghost
192.168.1.200 root loghost
我是这个Solaris VM 上的root 用户。我需要做什么改变才能使其正常工作?
我在日志文件中收到此消息
From MAILER-DAEMON Thu Feb 14 20:20:06 2013
Return-Path: <>
Received: from unknown (localhost [127.0.0.1])
by unknown (8.14.4+Sun/8.14.4) with ESMTP id r1F1K57F002411
for <root@unknown>; Thu, 14 Feb 2013 20:20:06 -0500 (EST)
Received: from localhost (localhost)
by unknown (8.14.4+Sun/8.14.4/Submit) id r1F1K51c002398;
Thu, 14 Feb 2013 20:20:06 -0500 (EST)
Date: Thu, 14 Feb 2013 20:20:06 -0500 (EST)
From: Mail Delivery Subsystem <MAILER-DAEMON@unknown>
Message-Id: <201302150120.r1F1K51c002398@unknown>
To: root@unknown
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="r1F1K51c002398.1360891206/unknown"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
Content-Length: 1287
This is a MIME-encapsulated message
--r1F1K51c002398.1360891206/unknown
答案1
正如评论中所示,您应该配置 sendmail。最有可能的是,您唯一需要的就是编辑 sendmail.conf 并为中继主机设置 DS“IP”。
还要确保您的主邮件服务器接受来自虚拟机的邮件。