yo8192 / fcron

fcron is an advanced cron for Linux/Unix systems
http://fcron.free.fr
GNU General Public License v2.0
131 stars 12 forks source link

mailfrom: possibly malformed sender address or Zoho SMTP too picky? (nullmailer MTA + Zoho mail) #15

Closed sphakka closed 3 weeks ago

sphakka commented 2 years ago

Hi there,

I set up the nullmailer MTA to send fcron (v3.2.1) mails to a Zoho mail account, but jobs' output/fail messages can't be delivered. Zoho mail SMTPD complains: "553 Relaying disallowed" .

My /etc/crontab is configured with:

!mailfrom(root@************)
!mailto(root@************)

Here's one of the failing message as processed by nullmailer (just showing the relevant bits):

root@************ (fcron)
************@************

Received: (nullmailer pid 26893 invoked by uid 1000);
    Mon, 25 Oct 2021 18:54:10 -0000
...
Message-Id: <1635188050.541402.26892.nullmailer@************>
From: root <root@************ (fcron)>

And the relative nullmailer's log snippet:

Starting delivery: host: smtp.zoho.com protocol: smtp file: 1635188050.26893
From: <root@************ (fcron)> to: <*********@***********>
Message-Id: <1635188050.541402.26892.nullmailer@****************>
smtp: Failed: 553 Relaying disallowed as root@*************** (fcron)
Sending failed: Permanent error in sending the message

As job.c reads at lines 321-322:

/* write mail header */
fprintf(mailf, "From: %s%s (fcron)\n", mailfrom, hostname_from);

the string (fcron) is appended to the original sender. I don't know if that causes a malformed header (not clear to me; cf. the 'domain' part of 'addr-spec'' here: https://datatracker.ietf.org/doc/html/rfc2822#section-3.4.1) or Zoho SMTPD is too picky. However, if I manually edit the message above, remove that extra string and resubmit it to nullmailer (just moving it back to its spooler), the email is correctly delivered! Meanwhile, I also raised the issue with the Zoho helpdesk...

BTW, it might be nice to have an extra option to not, er..., mangle the "From:" header.

lourdas commented 1 year ago

Having the same issue. This simple patch works for me in my Gentoo box:

diff -uNr fcron.old/job.c fcron/job.c
--- fcron.old/job.c 2021-12-05 20:02:10.000000000 +0200
+++ fcron/job.c 2023-03-21 18:39:39.133120000 +0200
@@ -319,7 +319,7 @@
#endif                          /* HAVE_GETHOSTNAME */

    /* write mail header */
-    fprintf(mailf, "From: %s%s (fcron)\n", mailfrom, hostname_from);
+    fprintf(mailf, "From: %s%s\n", mailfrom, hostname_from);
    fprintf(mailf, "To: %s%s\n", line->cl_mailto, hostname_to);

    if (subject)

It removes the (fcron) word from the sender address, which seems to cause the trouble. If a newer version would come out with the merge request applied, it'd be great.

yo8192 commented 3 weeks ago

Fixed by #17 and #33