Subject: Problem with mail_fetchbody

From: LYNX <[email-masked]>
Date: Mon, 12 May 1997 19:53:55 +0800 (HKT)

Hi,
	 I am having problem with mail_fetchbody(). If I call
	mail_fetchbody(stream, msgno, "X", &len), it returns X AND all 
sequent sections(but the length len is of the length of section X only).

What gives? I thought it only returned the relevant sections(as Internal.DOC
describe)?

Thanks for your time.

P.S: Please consider updating Internal.DOC. I didn't even know
there was rfc822_binary() until I looked at the source code!

---

From: Colin Burgess <[email-masked]>
Date: Mon, 12 May 1997 11:39:55 -0400 (EDT)

> What gives? I thought it only returned the relevant sections(as Internal.DOC
Your mistake is in assuming that the returned text will be null terminated -
this is not true.  You MUST note the length passed back to you.

> there was rfc822_binary() until I looked at the source code!
The current 4.1 is in BETA - Mark is very busy writing new source.
I'm sure that he will update the docs when he is ready. :)

Happy function hunting!

-- 
[email-masked]

---

From: Mark Crispin <[email-masked]>
Date: Mon, 12 May 1997 09:04:45 -0700 (PDT)

> What gives? I thought it only returned the relevant sections(as Internal.DOC

When a length value is returned, you must use the length and not assume that
the strings are null-terminated.  It is often the case that the return strings
are extracted from a cache of larger data (e.g. the entire message text).
Creating a NUL-terminated string without damaging the cache would require
making a copy.  c-client is working toward using *less* RAM, not more.

It is never safe to assume null-termination; NUL can appear in the text of a
message (although newer standards are working to outlaw that practice).

> there was rfc822_binary() until I looked at the source code!

In general, rfc822_binary() is only called internally by rfc822_output().
Only advanced applications do their own creation of BASE64 texts, and the
authors of such applications have to look at the rfc822_output() code to see
what they need to do anyway.

---

From: LYNX <[email-masked]>
Date: Tue, 13 May 1997 22:08:14 +0800 (HKT)

Hi,
	Thanks for the help.
	I now have another question.Basically I am finding a way to pipe 
a mail message to sendmail after the user has finished composing the mail. 
But I can't find any function that parses an ENVELOPE and BODY, and then 
returns the WHOLE message as a string.(kind of like mail_fetchtext())

	I have tried using rfc822_output(char *t, env, body, soutr_t mta,
FILE *f, ok8bit) where f = popen("sendmail ...", "w") and mta is a function
which pipes the into char * to f. Only the header t gets written to the
stream.

Thx to all.

---

From: Mark Crispin <[email-masked]>
Date: Tue, 13 May 1997 08:32:08 -0700 (PDT)

> which pipes the into char * to f. Only the header t gets written to the

That would happen if you don't have the "body" argument set up with a proper
body structure with useful data.

It can also happen if your "mta" function returns NIL, meaning that it failed.