Browse Source

Add headers options

tags/v0.1.0
Damien Goutte-Gattat 9 years ago
parent
commit
bd3c032436
1 changed files with 36 additions and 1 deletions
  1. +36
    -1
      src/fmail.c

+ 36
- 1
src/fmail.c View File

@@ -49,6 +49,16 @@ Read a mail from standard input and send it.\n");
-v, --version Display the version message.\n\
");

puts("\
Headers options:\n\
-H, --header \"NAME: TEXT\"\n\
Add an arbitrary header.\n\
-F, --from TEXT Set the From: header.\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\
");

puts("\
Attachments options:\n\
-a, --attach FILE Attach the specified file.\n\
@@ -386,6 +396,11 @@ main(int argc, char *argv[])
{ "version", 0, NULL, 'v' },
{ "sign", 0, NULL, 's' },
{ "attach", 1, NULL, 'a' },
{ "header", 1, NULL, 'H' },
{ "from", 1, NULL, 'F' },
{ "to", 1, NULL, 'T' },
{ "cc", 1, NULL, 'C' },
{ "subject", 1, NULL, 'S' },
{ NULL, 0, NULL, 0 }
};

@@ -399,7 +414,7 @@ main(int argc, char *argv[])
attachments = NULL;
att_count = 0;

while ( (c = getopt_long(argc, argv, "hvsa:",
while ( (c = getopt_long(argc, argv, "hvsa:H:F:T:C:S:",
options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
@@ -423,6 +438,26 @@ main(int argc, char *argv[])
attachments = xrealloc(attachments, att_count + 10);
attachments[att_count++] = optarg;
break;

case 'H':
sb_addf(headers, "%s\r\n", optarg);
break;

case 'F':
sb_addf(headers, "From: %s\r\n", optarg);
break;

case 'T':
sb_addf(headers, "To: %s\r\n", optarg);
break;

case 'C':
sb_addf(headers, "Cc: %s\r\n", optarg);
break;

case 'S':
sb_addf(headers, "Subject: %s\r\n", optarg);
break;
}
}



Loading…
Cancel
Save