cron doesn't support MAILFROM

Bug #1750051 reported by Simon Déziel
This bug affects 14 people
Affects Status Importance Assigned to Milestone
cron (Debian)
Fix Released
cron (Ubuntu)

Bug Description

Ubuntu's cron version doesn't support setting MAILFROM to set the "From:" header of cron generated emails. This feature would be nice to have and bring parity with RHEL/CentOS which has it since RHEL 6:

$ cat /etc/redhat-release
CentOS release 6.6 (Final)

$ man 5 crontab | grep -1 FROM
       doesn´t do aliasing, and UUCP usually doesn´t read its mail. If MAIL-
       FROM is defined (and non-empty), it will be used as the envelope sender
       address, otherwise, ‘‘root’’ will be used.

$ apt-cache policy cron
  Installed: 3.0pl1-128ubuntu2
  Candidate: 3.0pl1-128ubuntu2
  Version table:
 *** 3.0pl1-128ubuntu2 500
        500 xenial/main amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: cron 3.0pl1-128ubuntu2
ProcVersionSignature: Ubuntu 4.4.0-116.140-generic 4.4.98
Uname: Linux 4.4.0-116-generic x86_64
NonfreeKernelModules: zfs zunicode zcommon znvpair zavl
ApportVersion: 2.20.1-0ubuntu2.15
Architecture: amd64
CurrentDesktop: Unity
Date: Fri Feb 16 15:52:54 2018
InstallationDate: Installed on 2016-12-06 (436 days ago)
InstallationMedia: Ubuntu-Server 16.04.1 LTS "Xenial Xerus" - Beta amd64 (20161206)
SourcePackage: cron
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Simon Déziel (sdeziel) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cron (Ubuntu):
status: New → Confirmed
tags: added: bionic
Changed in cron (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Low
Revision history for this message
niconil (laurent-combe) wrote :

submit a patch to add the feature.

Heavily inspired from cronie project :

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "patch.txt" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Simon Déziel (sdeziel) wrote :

I looked at the patch (didn't test it) and I think the fprintf call is missing an argument to format as a string. It should read like this IMHO:

- fprintf(mail, "From: root (Cron Daemon)\n");
+ fprintf(mail, "From: %s\n", mailfrom);

Revision history for this message
niconil (laurent-combe) wrote :

you're right
only adding 6 lines and one bug inside :-(

new patch with the corrected line

niconil (laurent-combe)
Changed in cron (Debian):
importance: Undecided → Unknown
status: New → Unknown
Changed in cron (Debian):
status: Unknown → New
Revision history for this message
crash (crash369) wrote :

Another issue with this is that setting the "From:" header to "root (Cron daemon)" makes it difficult to forward this mail outside of the system. Many servers (like gmail) will bounce emails with an improper "From:" header.

Revision history for this message
Gordan Krešić (gordan-kresic) wrote :

It looks I accidentally changed status of this bug from "Triaged" to "Fix Released" (I clicked "fix released" in hope it will take me to the version in which it was fixed, but that wasn't a link, but an update action).

I'm not sure how I even could change status, since I'm not maintainer. I've tried, but I cannot revert this change.

Anyway, please somebody, revert status of tris to "Triaged".

Changed in cron (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
niconil (laurent-combe) wrote :

to answer #7
if you set an improper value to MAILFROM ok
but if you give to From field a correct value there is no reason to not be forwarded

locally i've patched my cron deamon and there is no particular problem

Changed in cron (Ubuntu):
status: Fix Released → Triaged
Revision history for this message
elatllat (elatllat) wrote :

CentOS 8 is not out yet so Ubuntu 18.04 is the best LTS for servers at the moment ... except for bugs like this.

Revision history for this message
niconil (laurent-combe) wrote :

a bug report with a patch submitted and no news since one year ... what can we do to make it accepted more quickly ?

Revision history for this message
Kermina Awad (kerminaawad) wrote :

I also just ran into a case where this would make my life much easier. Any idea on when we can expect this?

Changed in cron (Debian):
status: New → Fix Released
Revision history for this message
kubuntu (iooubuntu) wrote :

Hi what is the status of this bug? It says " Fix Released " does that mean it is fixed, is so what version? I am using Ubuntu 22.04.1 LTS and I cannot get cron to accept the MAILFROM directive. No matter what I do it always defaults to root. Unfortunately I can't get any notification from cron without properly filling out this field.

The man page says it should work. I have spend many hours trying to get this to work and looking for work around. Please confirm the status of this bug, if it has indeed been fixed and if so what version. Thank you.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.