Sending mail through terminal

Discussion in 'macOS' started by TurboLag, May 12, 2008.

  1. TurboLag macrumors member

    Feb 24, 2004
    I have a few cron jobs which periodically check my RAID status and disk usage. I would like to have the outcome emailed to myself. The proper syntax for sending mail through terminal is mail -s "subject", however nothing is sent. I know my cron jobs work as I had the outputs redirected to a file.

    How does the mail application know what mail server to send the email through? If it used the recipients email server, what happens if it requires authentication? How can I configure the /usr/bin/mail command to use a specific smpt server?
  2. SpaceMonkey2369 macrumors newbie


    Nov 7, 2009
    This worked for me:

    I know that this is an old thread, but I fixed this problem today and hope that my solution might aid somebody else who has the same difficulties.

    I could not receive mail from Cron, nor through the command line via 'mail' or 'sendmail' commands. Things that I had to do were:

    1) Edit /etc/postfix/ and find the line which starts with "myorigin=..." (it should be commented out by default). Put the domain name part of your own email address here, e.g. if your email address is "", then change the line to "".

    2) Find the line in the file which starts as "relayhost=..." (once again, should be commented out by default). Change this to fully qualified name of your mail server in square braces, e.g. "relayhost=[]". Don't forget the square braces or you will cause a host lookup error.

    3) When editing your crontab, make sure to include your required destination email address in the 'MAILTO' command, e.g. put the line "" at the start of your crontab file.

    That's it! Worked for me... Now getting mail from Cron and can send emails on the command line. :)

Share This Page