Skip to content

Commit 32d7284

Browse files
committed
Dont scan headers for cc abd bcc if extra parameters are used for these
1 parent 7afd927 commit 32d7284

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

win32/sendmail.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,28 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
414414
}
415415
efree(tempMailTo);
416416

417+
if (mailCc && *mailCc) {
418+
tempMailTo = estrdup(mailCc);
419+
/* Send mail to all rcpt's */
420+
token = strtok(tempMailTo, ",");
421+
while(token != NULL)
422+
{
423+
snprintf(Buffer, MAIL_BUFFER_SIZE, "RCPT TO:<%s>\r\n", token);
424+
if ((res = Post(Buffer)) != SUCCESS) {
425+
efree(tempMailTo);
426+
return (res);
427+
}
428+
if ((res = Ack(&server_response)) != SUCCESS) {
429+
SMTP_ERROR_RESPONSE(server_response);
430+
efree(tempMailTo);
431+
return (res);
432+
}
433+
token = strtok(NULL, ",");
434+
}
435+
efree(tempMailTo);
436+
}
417437
/* Send mail to all Cc rcpt's */
418-
if (headers && (pos1 = strstr(headers_lc, "cc:"))) {
438+
else if (headers && (pos1 = strstr(headers_lc, "cc:"))) {
419439
/* Real offset is memaddress from the original headers + difference of
420440
* string found in the lowercase headrs + 3 characters to jump over
421441
* the cc: */
@@ -444,8 +464,11 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
444464
efree(tempMailTo);
445465
}
446466

447-
if (mailCc && *mailCc) {
448-
tempMailTo = estrdup(mailCc);
467+
/* Send mail to all Bcc rcpt's
468+
This is basically a rip of the Cc code above.
469+
Just don't forget to remove the Bcc: from the header afterwards. */
470+
if (mailBcc && *mailBcc) {
471+
tempMailTo = estrdup(mailBcc);
449472
/* Send mail to all rcpt's */
450473
token = strtok(tempMailTo, ",");
451474
while(token != NULL)
@@ -464,11 +487,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
464487
}
465488
efree(tempMailTo);
466489
}
467-
468-
/* Send mail to all Bcc rcpt's
469-
This is basically a rip of the Cc code above.
470-
Just don't forget to remove the Bcc: from the header afterwards. */
471-
if (headers) {
490+
else if (headers) {
472491
if (pos1 = strstr(headers_lc, "bcc:")) {
473492
/* Real offset is memaddress from the original headers + difference of
474493
* string found in the lowercase headrs + 4 characters to jump over
@@ -526,27 +545,6 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
526545
}
527546
}
528547

529-
if (mailBcc && *mailBcc) {
530-
tempMailTo = estrdup(mailBcc);
531-
/* Send mail to all rcpt's */
532-
token = strtok(tempMailTo, ",");
533-
while(token != NULL)
534-
{
535-
snprintf(Buffer, MAIL_BUFFER_SIZE, "RCPT TO:<%s>\r\n", token);
536-
if ((res = Post(Buffer)) != SUCCESS) {
537-
efree(tempMailTo);
538-
return (res);
539-
}
540-
if ((res = Ack(&server_response)) != SUCCESS) {
541-
SMTP_ERROR_RESPONSE(server_response);
542-
efree(tempMailTo);
543-
return (res);
544-
}
545-
token = strtok(NULL, ",");
546-
}
547-
efree(tempMailTo);
548-
}
549-
550548
if ((res = Post("DATA\r\n")) != SUCCESS) {
551549
efree(stripped_header);
552550
return (res);

0 commit comments

Comments
 (0)