|
|
@ -1,6 +1,6 @@ |
|
|
|
/* |
|
|
|
* fmail - Mail formatter |
|
|
|
* Copyright (C) 2011 Damien Goutte-Gattat |
|
|
|
* Copyright (C) 2011,2018 Damien Goutte-Gattat |
|
|
|
* |
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
@ -67,6 +67,8 @@ for submission to a mail submission agent.\n"); |
|
|
|
-T, --to TEXT Add a To: header.\n\ |
|
|
|
-C, --cc TEXT Add a Cc: header.\n\ |
|
|
|
-S, --subject TEXT Set the Subject: header.\n\ |
|
|
|
-U, --user-agent Add a User-Agent: header.\n\ |
|
|
|
-D, --date Add a Date: header with the current date.\n\ |
|
|
|
"); |
|
|
|
|
|
|
|
puts("\ |
|
|
@ -490,22 +492,24 @@ read_input_from_editor(void) |
|
|
|
int |
|
|
|
main(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
char c; |
|
|
|
char c, with_useragent, with_date; |
|
|
|
string_buffer_t *headers; |
|
|
|
fmail_ctx_t ctx; |
|
|
|
|
|
|
|
struct option options[] = { |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ "version", 0, NULL, 'v' }, |
|
|
|
{ "sign", 0, NULL, 's' }, |
|
|
|
{ "attach", 1, NULL, 'a' }, |
|
|
|
{ "edit", 0, NULL, 'e' }, |
|
|
|
{ "footer", 1, NULL, 'f' }, |
|
|
|
{ "header", 1, NULL, 'H' }, |
|
|
|
{ "from", 1, NULL, 'F' }, |
|
|
|
{ "to", 1, NULL, 'T' }, |
|
|
|
{ "cc", 1, NULL, 'C' }, |
|
|
|
{ "subject", 1, NULL, 'S' }, |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ "version", 0, NULL, 'v' }, |
|
|
|
{ "sign", 0, NULL, 's' }, |
|
|
|
{ "attach", 1, NULL, 'a' }, |
|
|
|
{ "edit", 0, NULL, 'e' }, |
|
|
|
{ "footer", 1, NULL, 'f' }, |
|
|
|
{ "header", 1, NULL, 'H' }, |
|
|
|
{ "from", 1, NULL, 'F' }, |
|
|
|
{ "to", 1, NULL, 'T' }, |
|
|
|
{ "cc", 1, NULL, 'C' }, |
|
|
|
{ "subject", 1, NULL, 'S' }, |
|
|
|
{ "user-agent", 0, NULL, 'U' }, |
|
|
|
{ "date", 0, NULL, 'D' }, |
|
|
|
{ NULL, 0, NULL, 0 } |
|
|
|
}; |
|
|
|
|
|
|
@ -513,6 +517,8 @@ main(int argc, char *argv[]) |
|
|
|
setlocale(LC_ALL, ""); |
|
|
|
srand(time(NULL)); |
|
|
|
|
|
|
|
with_useragent = with_date = 0; |
|
|
|
|
|
|
|
headers = sb_new(0); |
|
|
|
ctx.signing_ctx = NULL; |
|
|
|
ctx.magic_ctx = initialize_magic(); |
|
|
@ -574,12 +580,22 @@ main(int argc, char *argv[]) |
|
|
|
case 'S': |
|
|
|
sb_addf(headers, "Subject: %s\r\n", optarg); |
|
|
|
break; |
|
|
|
|
|
|
|
case 'U': |
|
|
|
with_useragent = 1; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'D': |
|
|
|
with_date = 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* Generate automatic headers */ |
|
|
|
sb_addf(headers, "Date: %s\r\n", rfc2822_date()); |
|
|
|
sb_addf(headers, "User-Agent: fmail %s\r\n", VERSION); |
|
|
|
if ( with_date ) |
|
|
|
sb_addf(headers, "Date: %s\r\n", rfc2822_date()); |
|
|
|
if ( with_useragent ) |
|
|
|
sb_addf(headers, "User-Agent: fmail %s\r\n", VERSION); |
|
|
|
|
|
|
|
/* Fire editor instead of reading from stdin? */ |
|
|
|
if ( ! ctx.input ) |
|
|
|