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,
int rc;
size_t offset = 0;
header_t hdr;
body_t body;
int found_nl = 0;
message_get_stream (msg, &stream);
message_get_header (msg, &hdr);
header_get_stream (hdr, &stream);
if (message_get_header (msg, &hdr)
&& header_get_value (hdr, MU_HEADER_FCC, NULL, 0, NULL) == 0)
{
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending headers...\n");
while ((status = stream_readline (stream, buffer, sizeof (buffer),
offset, &len)) == 0
&& len != 0)
{
if (strncasecmp (buffer, MU_HEADER_FCC,
sizeof (MU_HEADER_FCC) - 1) == 0)
continue;
sizeof (MU_HEADER_FCC) - 1))
{
if (write (sendmail->fd, buffer, len) == -1)
{
status = errno;
......@@ -371,11 +371,29 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
break;
}
}
found_nl = (len == 1 && buffer[0] == '\n');
offset += len;
sendmail->offset += len;
}
if (!found_nl)
{
if (write (sendmail->fd, "\n", 1) == -1)
{
status = errno;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"write() failed: %s\n", strerror (status));
}
}
message_get_body (msg, &body);
body_get_stream (body, &stream);
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending body...\n");
offset = 0;
while ((status = stream_read (stream, buffer, sizeof (buffer),
offset, &len)) == 0
&& len != 0)
......