@@ -414,8 +414,28 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
414
414
}
415
415
efree (tempMailTo );
416
416
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
+ }
417
437
/* Send mail to all Cc rcpt's */
418
- if (headers && (pos1 = strstr (headers_lc , "cc:" ))) {
438
+ else if (headers && (pos1 = strstr (headers_lc , "cc:" ))) {
419
439
/* Real offset is memaddress from the original headers + difference of
420
440
* string found in the lowercase headrs + 3 characters to jump over
421
441
* the cc: */
@@ -444,8 +464,11 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
444
464
efree (tempMailTo );
445
465
}
446
466
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 );
449
472
/* Send mail to all rcpt's */
450
473
token = strtok (tempMailTo , "," );
451
474
while (token != NULL )
@@ -464,11 +487,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailB
464
487
}
465
488
efree (tempMailTo );
466
489
}
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 ) {
472
491
if (pos1 = strstr (headers_lc , "bcc:" )) {
473
492
/* Real offset is memaddress from the original headers + difference of
474
493
* 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
526
545
}
527
546
}
528
547
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
-
550
548
if ((res = Post ("DATA\r\n" )) != SUCCESS ) {
551
549
efree (stripped_header );
552
550
return (res );
0 commit comments