3

I am trying to familiarize myself with crontab. I know that it is supposed to send an email containing the output of jobs to the user that scheduled them however, I can see in the syslog that the address crontab is sending emails to is not a "local" one (as if I were to type mail -s "email here" username) but an external email address (like [email protected]).

Can someone tell me from where this email is derived and how I can set the users' email address to something else?

This could be because I have a top-level domain associated with my instance (I can see in the log the emails are being sent there), however, I actually have two domain names pointed to this server so I don't know how crontab is choosing or what would happen if there were no domain on this machine.

In short I am just trying to figure out where this default email address is set.

2
  • On what operating system? The capabilities to send emails to non-local users depends on the cron implementation. And what MTA (mail server software, e.g. postfix, exim, etc.) are you using? It may be the MTA that's doing the rewriting. Commented Aug 17, 2016 at 21:47
  • This is for Ubuntu Linux. What is strange to me is that, until I installed mailutils, I could not even use the mail program, therefore I do not know how cron would have sent an email (even to local users).
    – Startec
    Commented Aug 18, 2016 at 5:05

2 Answers 2

3

man 5 crontab

       If MAILTO is defined (and non-empty), mail  is  sent
       to the user so named.  MAILTO may also be used to direct mail to multi‐
       ple recipients by separating recipient users with a comma.
3
  • 2
    Good find! Unfortunately this does not explain where mail is sent if MAILTO is not defined and does not answer my question.
    – Startec
    Commented Aug 17, 2016 at 4:43
  • 4
    user@cat /etc/mailname or how you configured your mta. it's not crontab's job to choose address, it always addresses the local user. Commented Aug 17, 2016 at 4:47
  • 1
    Ah, there is the answer I am looking for. So it appends the users' name onto how the mta was configured. I see, thank you.
    – Startec
    Commented Aug 17, 2016 at 4:50
0

POSIX specifies that output should be mailed, but not how, so the answer is implementation-dependent, and there are unfortunately numerous cron implementations. If you aren't sure which cron daemon package you use, try the manual page for the crontab file: man 5 crontab

Vixie Cron

The most influential implementation is Paul Vixie's, which offers MAILTO. In Debian 11 and Ubuntu up to 23.10, the manpage of Vixie Cron reads:

If MAILTO is defined (and non-empty), mail is sent to the user so named. MAILTO may also be used to direct mail to multiple recipients by separating recipient users with a comma. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab.

Example

MAILTO="[email protected],[email protected]"

Manual pages

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.