bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] Adding subject in msg-send.c


From: Alain Magloire
Subject: Re: [bug-mailutils] Adding subject in msg-send.c
Date: Thu, 6 Mar 2003 23:11:17 -0500 (EST)

> 
> On Thu, Mar 06, 2003 at 05:15:42PM +0900, Kidong Lee wrote:
> > Hello, 
> > 
> > When I try to add Subject header in examples/msg-send.c(see diff file),
> > But there's no Subject header in the received mail.(The patch has no 
> > effect.)
> > On the contrary, When I comment out message_set_stream()(at 121 line,
> > version 0.3), there's Subject header in the mail.(In this case, there's
> > no body, of course)
> > 
> > There seems to be some kind of conflict between message_set_stream() and 
> > message_set_header().
> > 
> > Is it bug? or is there any fault?
> > 
> > ---------------
> > 
> > $ diff msg-send.c.orig msg-send.c
> > 69a70
> > >   header_t hdr = 0;
> > 120d120
> > <   C (message_set_stream (msg, in, NULL));
> > 121a122,125
> > > 
> > >   C (header_create (&hdr, NULL, 0, msg));
> > >   C (header_set_value (hdr, "Subject", "subject test", 1));
> > >   C (message_set_header(msg, hdr, NULL));
> > 
> 
> I made mistake in attaching diff file
> There's correct diff file.
> 
> ----------------
> 
> $ diff msg-send.c.orig msg-send.c
> 69a70
> >   header_t hdr = 0;
> 121a123,126
> > 
> >   C (header_create (&hdr, NULL, 0, msg));
> >   C (header_set_value (hdr, "Subject", "subject test", 1));
> >   C (message_set_header(msg, hdr, NULL));
> 

Hello

  I did not have time to test this, but the way things work:

a message(message_t) is a container of 2 objects,
header(header_t) and body(body_t)

Each object will have a stream corresponding:

header_t --> header_stream 
body_t   --> body_stream 

and the message stream is :

message_stream = header_stream  + body_stream

But if after setting the header on the message you reset the message stream
to something different then you no longer have:

message_stream != header_stream  + body_stream

So whatever you set on the header will no be seen when you read the
stream of the message (now you can argue this is a bug and calling
message_set_stream() should not be permitted after ..)

If you want to change the content of the email
You should reset the *body* of the message, see mail/send.c

header_create (&hdr, NULL, 0, NULL);
header_set_value (hdr, "Subject", "subject test", 1);
message_set_header (msg, hdr, NULL);

body_t body;
message_get_body(msg, &body);
body_get_stream(body, &body_stream);

// Write the email content.
stream_write(body, ....);


Now when the mailer/sendmail get the message stream to send the email
it should be ok:

message_stream = header_stream  + body_stream






reply via email to

[Prev in Thread] Current Thread [Next in Thread]