]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the formating of the e-mail subject
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 6 Jan 2012 14:00:35 +0000 (14:00 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 6 Jan 2012 14:00:35 +0000 (14:00 +0000)
The date in the subject line of the e-mail was produced with asctime.
But that function append a \n at the end of the date. The subject line
was therefore followed by a blank line as mailx was concerned and that
would mess with the header of the e-mail.

This patch render the subject line using strftime. It avoid the line
break and allow mailx to add additional headers from the command line.

email.c

diff --git a/email.c b/email.c
index d034b7736e654cdc236ee97f61cede5cf7dc27af..cf3a38b69dea2170a7d3a6e13cc4482ac05dea98 100644 (file)
--- a/email.c
+++ b/email.c
@@ -46,7 +46,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
        char strip1[MAXLEN], strip2[MAXLEN], strip3[MAXLEN], strip4[MAXLEN], strip5[MAXLEN], strip6[MAXLEN], strip7[MAXLEN];
        char *buf;
        char warea[MAXLEN];
-       char Subject[100];
+       char Subject[120];
        int totuser=0;
        time_t t;
        struct tm *local;
@@ -273,8 +273,12 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                while(fgets(warea,sizeof(warea),fp_top3)!=NULL)
                        fputs(warea,stdout);
        } else {
-               snprintf(Subject,sizeof(Subject),_("SARG report, %s"),asctime(local));
+               /* TRANSLATORS: The string is formatted using strftime. You can use
+                * any string formatting marker allowed by strftime. */
+               strftime(Subject,sizeof(Subject),_("SARG report, %c"),local);
                snprintf(warea,sizeof(warea),"%s -s \"%s\" \"%s\" <\"%s\"",MailUtility,Subject,email,top3);
+               if (debug)
+                       debuga(_("Sending mail with command: %s\n"),warea);
                cstatus=system(warea);
                if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                        debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));