Commit d04303ac d04303ac57734d886a3c88f64ae8d22f8217413a by Sergey Poznyakoff

(sendmail_send_message): Use header

and body streams sequentially instead of using message
stream. This allows to catch the modified/added headers.
1 parent ce09351c
...@@ -348,20 +348,20 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, ...@@ -348,20 +348,20 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
348 int rc; 348 int rc;
349 size_t offset = 0; 349 size_t offset = 0;
350 header_t hdr; 350 header_t hdr;
351 body_t body;
352 int found_nl = 0;
351 353
352 message_get_stream (msg, &stream); 354 message_get_header (msg, &hdr);
355 header_get_stream (hdr, &stream);
353 356
354 if (message_get_header (msg, &hdr) 357 MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending headers...\n");
355 && header_get_value (hdr, MU_HEADER_FCC, NULL, 0, NULL) == 0)
356 {
357 while ((status = stream_readline (stream, buffer, sizeof (buffer), 358 while ((status = stream_readline (stream, buffer, sizeof (buffer),
358 offset, &len)) == 0 359 offset, &len)) == 0
359 && len != 0) 360 && len != 0)
360 { 361 {
361 if (strncasecmp (buffer, MU_HEADER_FCC, 362 if (strncasecmp (buffer, MU_HEADER_FCC,
362 sizeof (MU_HEADER_FCC) - 1) == 0) 363 sizeof (MU_HEADER_FCC) - 1))
363 continue; 364 {
364
365 if (write (sendmail->fd, buffer, len) == -1) 365 if (write (sendmail->fd, buffer, len) == -1)
366 { 366 {
367 status = errno; 367 status = errno;
...@@ -371,11 +371,29 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, ...@@ -371,11 +371,29 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
371 371
372 break; 372 break;
373 } 373 }
374 }
375 found_nl = (len == 1 && buffer[0] == '\n');
376
374 offset += len; 377 offset += len;
375 sendmail->offset += len; 378 sendmail->offset += len;
376 } 379 }
380
381 if (!found_nl)
382 {
383 if (write (sendmail->fd, "\n", 1) == -1)
384 {
385 status = errno;
386
387 MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
388 "write() failed: %s\n", strerror (status));
389 }
377 } 390 }
378 391
392 message_get_body (msg, &body);
393 body_get_stream (body, &stream);
394
395 MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending body...\n");
396 offset = 0;
379 while ((status = stream_read (stream, buffer, sizeof (buffer), 397 while ((status = stream_read (stream, buffer, sizeof (buffer),
380 offset, &len)) == 0 398 offset, &len)) == 0
381 && len != 0) 399 && len != 0)
......