[Solved] Email from Command Line

I've set up Postfix on my Linode. The majority of emails are sent/received through Google Apps, but Postfix lets me create emails in PHP forms.

When I try to send an email via the command line though, I get

mail: command not found

I'm not sure how Postfix works, but is there another tool I should be installing to make this work, or is it something I can configure within Postfix?

Here's the script I'm running btw:

#!/bin/sh
( rkhunter --versioncheck
rkhunter --update
rkhunter --cronjob --report-warnings-only
) | mail -s "Rkhunter Output" michael@problogdesign.com

Really appreciate any ideas on what to try, thanks!

3 Replies

Sounds like you don't have the mailx package installed. How you do it depends on your distribution.

e.g., for CentOS:

yum install mailx

Or you could called the "sendmail" command (which postfix and most others emulate) directly.

It may be in /usr/lib or /usr/sbin (or both!)

eg

#!/bin/sh
(
  echo To: michael@problogdesign.com 
  echo Subject: Rkhunter Output
  echo
  rkhunter --versioncheck
  rkhunter --update
  rkhunter --cronjob --report-warnings-only
) | /usr/lib/sendmail -t

Sleddog - Ah, you're right, I haven't installed it. I didn't realize it was needed for the mail syntax, thanks! I'll remember that for the future! :)

Sweh - That worked perfectly, thanks so much! Using it now :D

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct