sendmail: don't add To: header if it already exists
If the message we are sending already has To: header, don't add a new one. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
236f222cde
commit
4a732220e9
@ -187,6 +187,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
HDR_BCC,
|
HDR_BCC,
|
||||||
} last_hdr = 0;
|
} last_hdr = 0;
|
||||||
int check_hdr;
|
int check_hdr;
|
||||||
|
int has_to = 0;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
//--- standard options
|
//--- standard options
|
||||||
@ -348,8 +349,10 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
// analyze headers
|
// analyze headers
|
||||||
// To: or Cc: headers add recipients
|
// To: or Cc: headers add recipients
|
||||||
|
check_hdr = 0 == strncasecmp("To:", s, 3);
|
||||||
|
has_to |= check_hdr;
|
||||||
if (opts & OPT_t) {
|
if (opts & OPT_t) {
|
||||||
if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) {
|
if (check_hdr || 0 == strncasecmp("Bcc:" + 1, s, 3)) {
|
||||||
rcptto_list(s+3);
|
rcptto_list(s+3);
|
||||||
last_hdr = HDR_TOCC;
|
last_hdr = HDR_TOCC;
|
||||||
goto addheader;
|
goto addheader;
|
||||||
@ -391,7 +394,9 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
rcptto(t);
|
rcptto(t);
|
||||||
//if (MAX_HEADERS && ++nheaders >= MAX_HEADERS)
|
//if (MAX_HEADERS && ++nheaders >= MAX_HEADERS)
|
||||||
// goto bail;
|
// goto bail;
|
||||||
llist_add_to_end(&list, xasprintf("To: %s", t));
|
if (!has_to)
|
||||||
|
llist_add_to_end(&list,
|
||||||
|
xasprintf("To: %s", t));
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
// enter "put message" mode
|
// enter "put message" mode
|
||||||
|
Loading…
Reference in New Issue
Block a user