diff -rub nbsmtp-1.00/main.c nbsmtp-1.00-patched/main.c --- nbsmtp-1.00/main.c 2005-07-28 10:29:07.000000000 -0700 +++ nbsmtp-1.00-patched/main.c 2006-02-14 15:21:20.000000000 -0800 @@ -48,7 +48,8 @@ { servinfo_t serverinfo; string_t msg_buffer; - string_t *rcpts = NULL; + string_t *rcpts = NULL, *msgrcpts = NULL; + int num_rcpts = 0; str_init(&msg_buffer, MAX_MSG_LEN); @@ -89,7 +90,9 @@ } } - switch (parse_options(argc,argv, &serverinfo)) + /* Pass in a pointer to rcpts in case the recipients were specified + * on the command line */ + switch (parse_options(argc, argv, &serverinfo, &rcpts)) { case 1: return 1; @@ -99,7 +102,8 @@ break; } - if((rcpts = parse_mail(&msg_buffer, &(serverinfo.num_rcpts))) == NULL) + + if( (msgrcpts = parse_mail(&msg_buffer, &num_rcpts)) == NULL) { log_msg(LOG_DEBUG, "Error in parse_mail"); if (debug > 0) @@ -117,6 +121,13 @@ #endif } + /* If no recipients specified on command line, use the ones we parsed + * out of the headers */ + if ( ! rcpts ) { + rcpts = msgrcpts; + serverinfo.num_rcpts = num_rcpts; + } + if(send_mail(&msg_buffer, &serverinfo, rcpts)) { log_msg(LOG_DEBUG, "Error in send_mail"); diff -rub nbsmtp-1.00/nbsmtp.8 nbsmtp-1.00-patched/nbsmtp.8 --- nbsmtp-1.00/nbsmtp.8 2005-05-17 08:59:46.000000000 -0700 +++ nbsmtp-1.00-patched/nbsmtp.8 2006-02-14 15:20:02.000000000 -0800 @@ -28,6 +28,11 @@ SASL Password .IP "-M [l|p|c]" SASL Method: l - AUTH LOGIN , p - AUTH PLAIN (default), c - AUTH CRAM-MD5 (only available when SSL compiled in) +.IP "-t \fIto-address\fP" +Envelope Recipient. Specifying a recipient with -t will override the +recipients discovered in the message headers. This is useful for so-called +\'bouncing\' of messages. You may use -t multiple times to specify more +envelope recipients. .IP "-s" If SSL compiled-in; use SSL to transfer the message .IP "-S" diff -rub nbsmtp-1.00/original.c nbsmtp-1.00-patched/original.c --- nbsmtp-1.00/original.c 2005-07-28 10:29:07.000000000 -0700 +++ nbsmtp-1.00-patched/original.c 2006-02-14 15:12:53.000000000 -0800 @@ -51,14 +51,17 @@ * \param[out] serverinfo A pointer to a servinfo_t struct * \return Returns 0 if everything went ok, 2 if we got -H (print long_help) and 1 in case of error */ -int parse_options(int argc,char *argv[], servinfo_t *serverinfo) +int parse_options(int argc, char *argv[], servinfo_t *serverinfo, + string_t **rcpts) { int c; char buffer[BUF_SIZE]; bool_t read_syswide = True; bool_t read_localconf = True; - for (c = 0 ; c < argc ; c++) + /* argv[0] = "nbsmtp" or whatever name was used to call the program. + * We don't need to check it as an option */ + for (c = 1 ; c < argc ; c++) { if (strncmp("-n",argv[c],strlen("-n"))==0) { @@ -78,7 +81,7 @@ } /* Then read the options */ - while ((c = getopt(argc,argv,"h:d:f:c:p:U:P:M:sSvVDHnN")) != -1) + while ((c = getopt(argc,argv,"h:d:f:c:p:U:P:M:t:sSvVDHnN")) != -1) { switch(c) { @@ -157,6 +160,20 @@ break; } break; + case 't': + serverinfo->num_rcpts += 1; + *rcpts = (string_t*) realloc(*rcpts, + (serverinfo->num_rcpts * + sizeof(string_t))); + if (! *rcpts) { + perror("realloc in parsing -t"); + return 1; + } + (*rcpts)[serverinfo->num_rcpts-1].str = + (char *)strdup(optarg); + (*rcpts)[serverinfo->num_rcpts-1].len = + strlen((*rcpts)[serverinfo->num_rcpts-1].str); + break; case 'H': print_help(argv[0]); return 2; diff -rub nbsmtp-1.00/original.h nbsmtp-1.00-patched/original.h --- nbsmtp-1.00/original.h 2005-07-28 10:29:07.000000000 -0700 +++ nbsmtp-1.00-patched/original.h 2006-02-14 01:49:15.000000000 -0800 @@ -32,4 +32,4 @@ string_t *parse_mail(string_t*,int*); int send_mail(string_t*,servinfo_t*,string_t*); int get_socket(servinfo_t*); -int parse_options(int,char*[],servinfo_t*); +int parse_options(int,char*[],servinfo_t*,string_t**); diff -rub nbsmtp-1.00/util.c nbsmtp-1.00-patched/util.c --- nbsmtp-1.00/util.c 2005-07-28 10:29:07.000000000 -0700 +++ nbsmtp-1.00-patched/util.c 2006-02-14 15:20:12.000000000 -0800 @@ -262,6 +262,8 @@ printf(" -v\tprint version and exit\n"); printf(" -c\tuse an additional config file\n"); printf(" -H\tthis help message\n"); + printf(" -t\tspecify envelope to:, overriding message headers\n"); + printf(" \tyou may use -t multiple times.\n"); printf("\nSend bug reports and comments to <%s>.\n\n",PACKAGE_BUGREPORT); }