Repository navigation
Cron mail is rejected due to missing domain #75
Copy link
Copy link
Open
Description
I'm using this configuration:
root@brix:/etc/dma# grep -vE '(^$|^#)' dma.conf
SMARTHOST localhost
MAILNAME /etc/mailname
MASQUERADE root@brix.MY.DOMAIN
to send all mails to a docker container running an smtp replay which accepts mail on port 25 and forwards it to
a mail hub using smtp auth.
I can send mail fine using the mail command like this:
echo hi | mail root
But cronmail is rejected because the From: header is root (Cron Daemon) without any domain.
My smtp relay rejects it with these message:
H=(brix.MY.DOMAIN) [172.17.0.1] F=<root@brix.MY.DOMAIN> rejected after DATA: header syntax (unqualified address not permitted: failing address in "From:" header is: roo
t (Cron Daemon)): unqualified address not permitted: failing address in "From:" header is: root (Cron Daemon)
Shortly after that, a bounce notification is also rejected:
H=(brix.MY.DOMAIN) [172.17.0.1] F=<> rejected after DATA: header syntax (missing or malformed local part: failing address in "From:" header is: MAILER-DAEMON <>): missing or malformed local part: failing address in "From:" header is: MAILER-DAEMON <>
And i end up having 2 mails in the /var/spool/dma/ spool directory:
root@brix:/etc# cat /var/spool/dma/M22152e.55d8f3dcc2f0
Received: from MAILER-DAEMON
id 22152e
by brix.MY.DOMAIN (DragonFly Mail Agent v0.11);
Wed, 05 Feb 2020 13:46:02 +0100
X-Original-To: <varac@MY.DOMAIN>
From: MAILER-DAEMON <>
To: root@brix.MY.DOMAIN
Subject: Mail delivery failed
Message-Id: <22152e@brix.MY.DOMAIN>
Date: Wed, 05 Feb 2020 13:46:02 +0100
This is the DragonFly Mail Agent v0.11 at brix.MY.DOMAIN.
There was an error delivering your mail to <varac@MY.DOMAIN>.
localhost [::1] did not like our final DATA:
550 header syntax
Message headers follow.
Received: from root (uid 0)
(envelope-from root@brix.MY.DOMAIN)
id 22152a
by brix.MY.DOMAIN (DragonFly Mail Agent v0.11);
Wed, 05 Feb 2020 13:46:01 +0100
From: root (Cron Daemon)
To: root
Subject: Cron <root@brix> fhkqrjhfb
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Date: Wed, 05 Feb 2020 13:46:01 +0100
Message-Id: <5e3ab909.22152a.4756bd5d@brix.MY.DOMAIN>
root@brix:/etc# cat /var/spool/dma/Q22152e.55d8f3dcc2f0
ID: 22152e.55d8f3dcc2f0
Sender:
Recipient: varac@MY.DOMAIN
What am I doing wrong ? Unfortunatly you can't configure the From address for cron mails, so there's nothing I can do about this on cron's side.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
varac commentedon Feb 5, 2020
I also saw Make MASQUERADE config setting override -f
and tried latest master, but if I understand correctly, MASQUERADE only sets the
envelope from, not thefromheader right ?corecode commentedon Feb 5, 2020
That is correct, we don't rewrite header lines. You probably should configure your smarthost not to reject mails originating from your machines/cron.
varac commentedon Feb 5, 2020
But what happens when delivering directly to an smtp server which is not under my control ? I.e. the one from my mail provider ?
I think it would be a great feature to append the
MAILNAMEto anyfromaddress without a specific domain. This would solve this issue out of the box.varac commentedon Feb 5, 2020
If I'm not mistaken this is basically the discussion held in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697871, or am I wrong ?
corecode commentedon Feb 5, 2020
varac commentedon Feb 5, 2020
I would, but I can't since I haven't written a single line of C in my whole life!
varac commentedon Feb 5, 2020
But I'm happy to test any PR and give feedback.
vlyon commentedon Feb 7, 2020
Actually this is discussed here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830518, but is related to the one you mentioned. That bug has been partially fixed, but the unqualified
To:andFrom:headers are not being corrected.vlyon commentedon Feb 7, 2020
See related issue #21
varac commentedon Feb 7, 2020
@vlyon Thanks for the correct link, this debian bug report describes my issue pretty well.
varac commentedon Feb 12, 2020
@corecode Is there any chance to get this fixed soon ? Without this I need to look for another alternative, since recieving system/cron-mails is pretty important for me.
corecode commentedon Feb 12, 2020
trevor87 commentedon Sep 4, 2020
Did you find a solution to this? I am also having trouble to get DMA to work with anything else than gmail (e.g. gmx.net does not work).
vlyon commentedon Sep 7, 2020
I have found a workaround for this issue, and have been using it for some time now on Debian.
I use a simple perl script that I've written, to send email from cron via DMA.
In my
crontabI have the following line:SHELL=/home/somewhere/bin/cronshThen the
cronshscript contains:jjakob commentedon Apr 12, 2021
I've added header From rewriting to dma. I'll open a PR.
corecode commentedon Apr 12, 2021
jjakob commentedon Apr 14, 2021
#96
HenriGEIST commentedon Sep 5, 2024
If it can help I had the same problem and I have solved it by applying this diff against tag 'v0.13'
`
$ git diff
diff --git a/mail.c b/mail.c
index bf82d52..c0caae8 100644
--- a/mail.c
+++ b/mail.c
@@ -397,7 +397,9 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
* Ignore a leading RFC-976 From_ or >From_ line mistakenly
* inserted by some programs.
*/
`
It simply reject the first
From: root (Cron Daemon)As invalid just like firsts "From " and ">From ".
And in fact this is not a valid expeditor (At least in my point of view)
[Fix: corecode#75] Cron mail is rejected due to missing domain.
corecode commentedon Sep 6, 2024
From: root (Cron Daemon)is not invalid. The receiving mail server is configured to reject it.HenriGEIST commentedon Sep 6, 2024
OK may be not strictly speaking "invalid" by RFC criteria.
But wired, and rejected by all 3 smarthosts I have tried :
If most mail provider reject it, for my usage it is the same as "invalid".
I will keep the workaround on my fork as long as I have no better solution to get my cron report to find their way to my mailbox.
If it help someone else that's good. If not there is no harm.
corecode commentedon Sep 6, 2024
HenriGEIST commentedon Sep 6, 2024
I am not sure what you mean by "authenticate" but I always use login and password on the SMTP before sending a mail.
If I don't nothing goes by what ever I do with the "From:" line in the mail content.
My /etc/dma/dma.conf contain :
`
SMARTHOST mail.gandi.net
PORT 465
ALIASES /etc/aliases
AUTHPATH /etc/dma/auth.conf
SECURETRANSFER
MAILNAME /etc/mailname
MASQUERADE XXXXXXX@YYYYYYY.ZZZ
`
And my /etc/dma/auth.conf contain :
XXXXXXX@YYYYYYY.ZZZ|mail.gandi.net:WWWWWWEverything work well with the patch and fail silently without it.
No error message, /var/log/mail.log say "aaaaaaa@bbbbbbb.ccc delivery successful"
Just without the patch the mail never reach destination.
corecode commentedon Sep 6, 2024
HenriGEIST commentedon Sep 6, 2024
Maybe but exact same situation with 'smtp.laposte.net'.
HenriGEIST commentedon Sep 6, 2024
But in fact I do not now where exactly it is discarded.
Could be any intermediary server between the first smart host and the final pop/imap delivery server.
Could be an anti spam anywhere.
e-minguez commentedon Feb 18, 2025
Just in case, you can set MAILFROM in Debian's cron since https://salsa.debian.org/debian/cron/-/blob/master/debian/patches/features/Add-MAILFROM-environment-variable.patch?ref_type=heads