从localhost Ubuntu发送邮件需要安装什么软件包?

我在我的服务器上安装了Ubuntu。 我想让cronjobs发送邮件给我。

我怎样才能从terminal发送电子邮件。 我必须安装哪些东西,以及如何将该程序中的smtp或stream行设置

我相信mailx是你正在寻找的。

sudo apt-get install bsd-mailx 

这也将安装postfix至less,并会给你几个选项来设置postfix。 如果您的局域网上有SMTP服务器,请select“卫星系统”,然后input邮件域名,最后inputSMTP服务器的IP地址。

使用:

 echo $MESSAGE_BODY | /bin/mail -s "$SUBJECT" "$RECIPIENT_ADDRESS" 

您也可以使用文件的正文:

 /bin/mail -s "$SUBJECT" "$RECIPIENT_ADDRESS" < /tmp/message.txt 

ssmtp软件包很受欢迎,可以方便地从ubuntu机箱发送邮件。 这里是一个教程来设置它使用Gmail。

如果你不想搞乱configurationPostfix(这可能是一个可怕的痛苦),检出heirloom-mailx(sudo apt-get install heirloom-mailx)

这是邮件命令的替代版本,可让您指定外部SMTP服务器。 对于简单的cron脚本来说是理想的。

主页: http : //heirloom.sourceforge.net/mailx.html

手册页: http : //heirloom.sourceforge.net/mailx/mailx.1.html

安装postfix和mailx

apt-get安装postfix mailx

我在我的商店中使用了一个标准的设置,我发现mailutils包是完美的,比如从cronjobs发送自动邮件等。通过一个ncursesconfiguration助手很容易设置。

 sudo aptitude install mailutils sudo dpkg-reconfigure exim4-config 

internet site; mail is sent and received directly using SMTP的selectinternet site; mail is sent and received directly using SMTP internet site; mail is sent and received directly using SMTP最适合我(因为我想发送大部分)。 你也可以通过这个configuration来设置你的root转发地址。

然后你可以使用命令行(上面给出的例子)发送电子邮件,但我使用:

 mail -s "AVScan completed on HOSTNAME" [email protected] 

希望这可以帮助。

我做的最新的安装是在Ubuntu 11.10上的命令:

 sudo apt-get install postfix mailutils 

如果你想阅读关于postfix的更多信息,它是如何工作的以及如何testing它: PostfixBasicSetupHowto

然后你可以在cronjob中使用mail命令。 有关选项和用法,请参见命令手册页。