diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-06-07 22:46:36 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-06-07 22:46:36 +0300 |
commit | 1f48571ac189204221fc6d336ff432a8595820f2 (patch) | |
tree | e7c9b04390342b23bf7b22d7e0c81d4a7baf9e3e | |
parent | b6818d6d3c2078b595453f982996090de7619ebc (diff) | |
download | mailutils-1f48571ac189204221fc6d336ff432a8595820f2.tar.gz mailutils-1f48571ac189204221fc6d336ff432a8595820f2.tar.bz2 |
mail: Add a Date: header before sending the message
* mail/send.c (message_add_date): New function.
(mail_send0): Call message_add_date before sending the message.
-rw-r--r-- | mail/send.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mail/send.c b/mail/send.c index da565419e..35a5bc335 100644 --- a/mail/send.c +++ b/mail/send.c @@ -1208,6 +1208,33 @@ send_message (mu_message_t msg) return status; } +#define MU_DATETIME_RFC822_LENGTH 31 + +static void +message_add_date (mu_message_t msg) +{ + mu_header_t hdr; + char buf[MU_DATETIME_RFC822_LENGTH+1]; + struct tm ltm; + time_t t; + int rc; + + rc = mu_message_get_header (msg, &hdr); + if (rc) + { + mu_diag_funcall (MU_DIAG_ERROR, "mu_message_get_header", NULL, rc); + return; + } + + t = time (NULL); + localtime_r (&t, <m); + + mu_strftime (buf, sizeof (buf), MU_DATETIME_FORM_RFC822, <m); + rc = mu_header_set_value (hdr, MU_HEADER_DATE, buf, 1); + if (rc) + mu_diag_funcall (MU_DIAG_ERROR, "mu_header_set_value", MU_HEADER_DATE, rc); +} + /* mail_send0(): shared between mail_send() and mail_reply(); If the variable "record" is set, the outgoing message is @@ -1433,6 +1460,7 @@ mail_send0 (compose_env_t *env, int save_to) /* Do we need to Send the message on the wire? */ if (status == 0 && sendit) { + message_add_date (msg); status = send_message (msg); if (status) { |