Linux / UNIX Change Crontab Email Settings ( MAILTO )

I would like to send an email to instead of default system root user for crond service on a Linux or Unix-like system. How do I change the email settings under crontab file on a Linux or Unix-like systems?

A crontab file contains instructions to the cron daemon. It wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. When executing commands, any output is mailed to the owner of the crontab or to the user named in the MAILTO environment variable in the crontab, if such exists.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements cron on Linux/Unix
Est. reading time 1m

How To Change Crontab Email Settings ( MAILTO )

The MAILTO syntax is:
name = value
Where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in value will be part of the value assigned to name. The value string may be placed in quotes (single or double, but matching) to preserve leading or trailing blanks. The value string is not parsed for environmental substitutions, thus lines like:


will not work as you might expect.

Set MAILTO Variable To Change Crontab Email Setting

In addition to LOGNAME, HOME, and SHELL, cron will look at MAILTO if it has any reason to send mail as a result of running commands in “this” crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. First open your crontab file:
# vi /etc/crontab
$ crontab -e
To send email to, enter:
Let us send email local user named sai:
If MAILTO is defined but empty (MAILTO=””), no mail will be sent.
Otherwise email is sent to the owner of the crontab.


@midnight       /root/scripts/backup-servers
10 20 * * sun   /bin/php-cli /wwwroot/apps/cleanup.php
# We can switch email alert too
@daily /root/scripts/ 
* 10 * * * /root/scripts/
# Disable email alert for rest of jobs
5 0 * * *       /scripts/bin/ >> /tmp/daily.shoutput.txt 2>&1

A note about routing email outside of your network or local network

Setting MAILTO will not magically send an email. To send an email, you must have an email server running either on the same host or in your LAN. In other words, Linux and Unix users need an SMTP server like Sendmail or Postfix running. Most modern SMTP allows SMARTHOST where you can forward email using cloud computing or ISP email server. See the following tutorials:

Another option is to configure your Gmail account. See

This entry is 7 of 16 in the Linux Cron Jobs Howto & Tutorial series. Keep reading the rest of the series:
  1. What is cron on a Linux or Unix-like systems?
  2. How To Add Jobs To cron Under Linux or UNIX?
  3. Verify crond Daemon And Cronjobs Are Running
  4. Start Restart and Stop The Cron or Crond Service
  5. List / Display All Cron Jobs
  6. Linux / UNIX Crontab File Location
  7. Change Crontab Email Settings ( MAILTO )
  8. Disable The Mail Alert By Crontab Command On a Linux or Unix-like Systems
  9. At What Time Cron Entries In cron.daily, cron.weekly, cron.monthly Run?
  10. Execute Cron Job After System Reboot
  11. Setup and Run PHP Script As A Cron Job
  12. Run crontab job every minute on a Linux or Unix-like system
  13. Running crontab (cron jobs) Every 10 Minutes
  14. Cron Job Script Execution on the Last Day of a Month
  15. Execute / Run crontab (cron jobs) every 1 minute
  16. Ubuntu create cron.log file

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 18 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
18 comments… add one
  • Brock Tice Sep 20, 2008 @ 14:17

    Thanks, never even thought it could be changed, I always used my .forward for this. Very handy.

  • Darren Sep 20, 2008 @ 20:40

    I too have always the “.forward” option. This is done by the follwing…..

    create a new file called .forward
    vi /root/.forward

    Enter the email address on the first line in the file.

    Save (w) the file and exit (q)

    Now, anytime the ‘root’ user get an email, it will automatically be forwarded to the address you specified in the .forward file.

    You can also place the .forward file in users home directories /home/user1/.forward

    Thanks for the info up above though, I’ll have to check that out.

  • phanikumar Nov 26, 2008 @ 6:08

    Hi All,

    Please help me out..

    I configured cron job under FTPPKR user.i’ll get mails from whenever cron runs..But whenever i need the mails to be delivered from user.

    Is it possibe? If yes, please help me out..

  • Andre Jul 4, 2009 @ 8:15

    Yes, that’s entirely possible. Just figure out if the emails are being sent with sendmail or postfix, then adjust their settings to reflect that. You could deploy address rewrites to achieve this, for example.

  • maxo May 7, 2010 @ 19:48

    SOLARIS Unix does not support the MAILTO feature. Instead one needs to append the crontab entry with | mailto user@domain.
    For example:
    00 12 * * * | mail user@domain

  • Dmitri Minaev Sep 1, 2010 @ 5:25

    Mail addressed to ‘root’ is often redirected to some other account using /etc/aliases. You might like to edit (or add) the line beginning with ‘root:’ to point to some other account.

  • alex Jul 3, 2011 @ 2:33

    But, How if I dont want to receive notification from crontab? How to set it ? Because I’m monitoring mail server, and notification from crontab unnecessary for me.

  • martijn Jul 14, 2011 @ 6:02

    @alex: add >/dev/null 2>&1 to the end of your line(s) in crontab. This will redirect all crontab output to /dev/null

  • mehturt Jul 26, 2011 @ 15:42

    What command is cron using to send email? I’m trying to get cron working with esmtp, but no luck so far.

  • Alwin Doss Jan 23, 2013 @ 10:20

    I wanted to know under what circumstances will the email be sent.
    Is it only when cron encounters a warning or error
    Or even when the commad is executed succesfully

  • Pankaj Jun 4, 2013 @ 6:22

    I am new for cronjob so help me.
    How to send a automatically mail to fix mail address .

  • Irfan Jul 2, 2013 @ 7:39


    While using cronjob when my cronjob fails then the mail is sent to the user who is login but not to mailto user. What is required to send mail to the “mailto” user even when the test fails.

  • Sebastian May 28, 2014 @ 7:59

    I’ve setted up a new cron (rsync job), the first few days it mades errors which I get by email. Now it looks to work fine, but I don’t get an email. Someone knows why?

    thanks in advance

    • 🐧 Vivek Gite May 28, 2014 @ 9:54

      Check your server mail log file. Also, check your spam folder.

      • Sebastian Jun 2, 2014 @ 14:04

        Email with errors I receive. So I guess there is no try to send an email.

  • ramses Jun 21, 2014 @ 13:00

    i have this line in crontab could someone explain me what is the mean of this?
    thanks by advance
    #*/1 * * * * root /usr/local/rtm/bin/rtm 26 > /dev/null 2> /dev/null

    • mhmhI.mstfa Jun 1, 2015 @ 8:04

      this will run the /usr/local/rtm/bin/rtm script once every minute and redirects the output messages to /dev/null so as to get rid of them

    • utoddl Jun 15, 2016 @ 20:53

      Actually, that’s a comment; it starts with a #

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum