dma icon indicating copy to clipboard operation
dma copied to clipboard

Cron mail is rejected due to missing domain

Open varac opened this issue 5 years ago • 26 comments

I'm using this configuration:

root@brix:/etc/dma# grep -vE '(^$|^#)' dma.conf
SMARTHOST localhost
MAILNAME /etc/mailname
MASQUERADE [email protected]

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=<[email protected]> 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: <[email protected]>
From: MAILER-DAEMON <>
To: [email protected]
Subject: Mail delivery failed
Message-Id: <[email protected]>
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 <[email protected]>.

localhost [::1] did not like our final DATA:
550 header syntax

Message headers follow.

Received: from root (uid 0)
        (envelope-from [email protected])
        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: <[email protected]>
root@brix:/etc# cat /var/spool/dma/Q22152e.55d8f3dcc2f0
ID: 22152e.55d8f3dcc2f0
Sender:
Recipient: [email protected]

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.

varac avatar Feb 05 '20 12:02 varac

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 the from header right ?

varac avatar Feb 05 '20 13:02 varac

That is correct, we don't rewrite header lines. You probably should configure your smarthost not to reject mails originating from your machines/cron.

corecode avatar Feb 05 '20 15:02 corecode

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 MAILNAME to any from address without a specific domain. This would solve this issue out of the box.

varac avatar Feb 05 '20 17:02 varac

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 ?

varac avatar Feb 05 '20 17:02 varac

would you like to submit a PR for review?

On 05/02/2020 18:03, Varac wrote:

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 |MAILNAME| to any |from| address without a specific domain. This would solve this issue out of the box.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/corecode/dma/issues/75?email_source=notifications&email_token=AABLOO7IHIJJY2BAATOKSQTRBLWPFA5CNFSM4KQKU26KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK4GC6Y#issuecomment-582508923, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLOO4Z4CLG7MRC3B4UHOLRBLWPFANCNFSM4KQKU26A.

corecode avatar Feb 05 '20 17:02 corecode

would you like to submit a PR for review?

I would, but I can't since I haven't written a single line of C in my whole life!

varac avatar Feb 05 '20 20:02 varac

But I'm happy to test any PR and give feedback.

varac avatar Feb 05 '20 20:02 varac

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 ?

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: and From: headers are not being corrected.

vlyon avatar Feb 07 '20 11:02 vlyon

See related issue #21

vlyon avatar Feb 07 '20 11:02 vlyon

Actually this is discussed here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830518

@vlyon Thanks for the correct link, this debian bug report describes my issue pretty well.

varac avatar Feb 07 '20 12:02 varac

@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.

varac avatar Feb 12 '20 12:02 varac

Not by me - happy to review and merge pull requests.

On 12/02/2020 13:19, Varac wrote:

@corecode https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/corecode/dma/issues/75?email_source=notifications&email_token=AABLOO6TMWCXFNQM526GAW3RCPSOHA5CNFSM4KQKU26KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELQSEEI#issuecomment-585179665, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLOO4IELZ4GDVVCY5TWRLRCPSOHANCNFSM4KQKU26A.

corecode avatar Feb 12 '20 12:02 corecode

@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.

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).

trevor87 avatar Sep 04 '20 16:09 trevor87

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 crontab I have the following line: SHELL=/home/somewhere/bin/cronsh

Then the cronsh script contains:

#!/usr/bin/perl -CA
use 5.024;
use warnings;
use IPC::Run3;
use Email::Stuffer;

@ARGV == 2 and $ARGV[0] eq '-c' or die "Usage:\n$0 -c <command>\n";
my $out;
run3 $ARGV[1], undef, \$out, \$out, {return_if_system_error => 1};
if ($? or length $out) {
    utf8::decode $out;
    $out .= $! if $?;
    $out = Email::Stuffer
    ->from("Cron <$ENV{LOGNAME}\@myhostname.com>")
    ->to('"Vernon Lyon" <[email protected]>')
    ->subject($ARGV[1])
    ->text_body($out, encoding => '8bit')
    ->as_string;
    run3 [qw(/usr/sbin/dma -it)], \$out;
}

vlyon avatar Sep 07 '20 10:09 vlyon

I've added header From rewriting to dma. I'll open a PR.

jjakob avatar Apr 12 '21 12:04 jjakob

thanks!

On 12/04/2021 07:46, Jernej Jakob wrote:

I've added header From rewriting to dma. I'll open a PR.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/corecode/dma/issues/75#issuecomment-817780823, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLOOZB3GDCNN6QA4TIPODTILTSFANCNFSM4KQKU26A.

corecode avatar Apr 12 '21 14:04 corecode

https://github.com/corecode/dma/pull/96

jjakob avatar Apr 14 '21 15:04 jjakob