Since I switched to SMTPD I noticed a few cron emails being marked as
spam by spamassassin, largely caused by the From: and To: headers not
containing a domain part.

If I read RFC822 correctly, the domain part is not optional, and thus
we should append one, unless MAILTO already specifies one.

Historical reasons from the land of pre-smtp why I'm wrong?
Comments?
OK's?

/Alexander


(Indentation style sucks balls in there. I kept it up.)

Index: do_command.c
===================================================================
RCS file: /data/openbsd/cvs/src/usr.sbin/cron/do_command.c,v
retrieving revision 1.36
diff -u -p -r1.36 do_command.c
--- do_command.c        22 Aug 2011 19:32:42 -0000      1.36
+++ do_command.c        13 Nov 2012 09:48:53 -0000
@@ -412,8 +412,13 @@ child_process(entry *e, user *u) {
                                        perror(mailcmd);
                                        (void) _exit(EXIT_FAILURE);
                                }
-                               fprintf(mail, "From: root (Cron Daemon)\n");
-                               fprintf(mail, "To: %s\n", mailto);
+                               fprintf(mail, "From: root@%s (Cron Daemon)\n",
+                                       hostname);
+                               if (strchr(mailto, '@') == NULL)
+                                       fprintf(mail, "To: %s@%s\n", mailto,
+                                               hostname);
+                               else
+                                       fprintf(mail, "To: %s\n", mailto);
                                fprintf(mail, "Subject: Cron <%s@%s> %s\n",
                                        usernm, first_word(hostname, "."),
                                        e->cmd);

Reply via email to