Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was using the following mail command in my crontab to which worked flawlessly until we re installed our mail server last Friday:

echo "Testing 123" | mail -s "ECS PostDate Processed" "layton.everson@gmail.com chrish@mycreditcompany.com" -- -r "noreply@mycreditcompany.com" -F "ServerCronJobs"

previously the "--" would rout the command line parameters to sendmail to send from a name and add a reply-to address. Now it seems the -- is being ignored and all of the extra parameters are being treated as email addresses. so the email is going to:

from root <root@mycompany.com>
to me, chrish, -r, noreply, -F, ServerCronJobs

What is missing now?

share|improve this question
1  
What's the new and old version of the OS? You probably simply aren't running the same 'mail' command. Check man mail for the options. –  freiheit May 14 '13 at 22:01
add comment

1 Answer

You probably got a different version of the "mail" command with the OS upgrade, and it doesn't have the same options.

Why not just use sendmail directly, instead? That's a standardized command that unix MTAs always emulate, and is designed well for scripted usage:

( 
  echo "Subject: ECS PostDate Processed"
  echo "To: example.1@gmail.com, example2@mycreditcompany.com"
  echo "Reply-To: noreply@example.com"
  echo "From: ServerCronJobs <root@mycompany.com>"
  echo
  echo "Testing 123"
) | /usr/sbin/sendmail -oi -t

That can be done ( echo ; echo ; echo ) | sendmail style instead to fit on one line.

Or, if it is all just echo instead of a command somewhere in that pipe, replace with a 'here document':

/usr/sbin/sendmail -oi -t <<EOT
Subject: ECS PostDate Processed
To: example.1@gmail.com, example2@mycreditcompany.com 
Reply-To: noreply@example.com
From: ServerCronJobs <root@mycompany.com>

Testing 123

EOT
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.