o per rfc821,rfc5321 and others there should be an CRLF after each mail-headers line, so change '\n' to '\r\n' o enclose mail addresses between '<>' (rfc821) o swap From: line to DisplayName (rfc5312) Add various mail headers to suppress auto-replies (out of office ...) o add rfc2076 header (Precedence: bulk) o add rfc3834 header (Auto-Submitted: auto-generated) (this header is already honored by dovecot2) o add special header for MS Exchange (X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply) Index: head/usr.sbin/cron/cron/do_command.c =================================================================== --- head/usr.sbin/cron/cron/do_command.c (revision 244958) +++ head/usr.sbin/cron/cron/do_command.c (working copy) @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ Index: stable/7/usr.sbin/cron/cron/do_command.c =================================================================== --- stable/7/usr.sbin/cron/cron/do_command.c (revision 244958) +++ stable/7/usr.sbin/cron/cron/do_command.c (working copy) @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ Index: stable/8/usr.sbin/cron/cron/do_command.c =================================================================== --- stable/8/usr.sbin/cron/cron/do_command.c (revision 244958) +++ stable/8/usr.sbin/cron/cron/do_command.c (working copy) @@ -147,7 +147,7 @@ #ifdef USE_SIGCHLD /* our parent is watching for our death by catching SIGCHLD. we * do not care to watch for our children's deaths this way -- we - * use wait() explictly. so we have to disable the signal (which + * use wait() explicitly. so we have to disable the signal (which * was inherited from the parent). */ (void) signal(SIGCHLD, SIG_DFL); @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */ Index: stable/9/usr.sbin/cron/cron/do_command.c =================================================================== --- stable/9/usr.sbin/cron/cron/do_command.c (revision 244958) +++ stable/9/usr.sbin/cron/cron/do_command.c (working copy) @@ -147,7 +147,7 @@ #ifdef USE_SIGCHLD /* our parent is watching for our death by catching SIGCHLD. we * do not care to watch for our children's deaths this way -- we - * use wait() explictly. so we have to disable the signal (which + * use wait() explicitly. so we have to disable the signal (which * was inherited from the parent). */ (void) signal(SIGCHLD, SIG_DFL); @@ -488,19 +488,25 @@ warn("%s", MAILCMD); (void) _exit(ERROR_EXIT); } - fprintf(mail, "From: %s (Cron Daemon)\n", usernm); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", + fprintf(mail, "From: (Cron Daemon) <%s>\r\n", usernm); + fprintf(mail, "To: <%s>\r\n", mailto); + fprintf(mail, "Subject: Cron <%s@%s> %s\r\n", usernm, first_word(hostname, "."), e->cmd); + /* RFC3834 */ + fprintf(mail, "Auto-Submitted: auto-generated\r\n"); + /* RFC2076 */ + fprintf(mail, "Precedence: bulk\r\n"); + /* http://msdn.microsoft.com/en-us/library/ee219609%28v=EXCHG.80%29.aspx */ + fprintf(mail, "X-Auto-Response-Suppress: OOF, DR, RN, NRN, AutoReply\r\n"); # if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", + fprintf(mail, "Date: %s\r\n", arpadate(&TargetTime)); # endif /* MAIL_DATE */ for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", + fprintf(mail, "X-Cron-Env: <%s>\r\n", *env); - fprintf(mail, "\n"); + fprintf(mail, "\r\n"); /* this was the first char from the pipe */