| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I have a program that, upon an receiving an email it cannot process, needs to forward that email to someone with a description of the error. I've tried using rfc822_parse_msg_full() to do this for me by feeding it the output of mail_fetchheader_full and mail_fetchtext_full (after putting fetchtext's output into a stringstruct), and setting the max depth to MAXMIMEDEPTH-1. I get a message attachment, but it has no content. What am I missing? |
|
#2
| |||
| |||
| On Apr 18, 8:21 pm, mozuzae...@gmail.com wrote: > I have a program that, upon an receiving an email it cannot process, > needs to forward that email to someone with a description of the > error. > > I've tried using rfc822_parse_msg_full() to do this for me by feeding > it the output of mail_fetchheader_full and mail_fetchtext_full (after > putting fetchtext's output into a stringstruct), and setting the max > depth to MAXMIMEDEPTH-1. > > I get a message attachment, but it has no content. > > What am I missing? I'd like to add that the documentation found in internal.txt is inaccurate with regards to the BODY structure. |
|
#3
| |||
| |||
| On Fri, 18 Apr 2008, mozuzaeram@gmail.com posted: > I have a program that, upon an receiving an email it cannot process, > needs to forward that email to someone with a description of the > error. > > I've tried using rfc822_parse_msg_full() to do this for me by feeding > it the output of mail_fetchheader_full and mail_fetchtext_full (after > putting fetchtext's output into a stringstruct), and setting the max > depth to MAXMIMEDEPTH-1. Several mistakes here. First, rfc822_parse_msg_full() is an internal function. There is almost no reason why any application program should call that function. If you want the ENVELOPE and BODY structure of a message in the mailbox, use mail_fetch_structure(). Another likely mistake is an incorrect assumption that you can use the return values from mail_fetchheader_full() and mail_fetchtext_full() simultaneously. The same buffer can be reused by these functions. If you need both strings simultaneously, you have to make a copy of one (typically via cpystr() on the header since it's shorter) before calling the other. Note as well that mail_fetchtext_full() converts a stringstruct from the drivers into a char* string, so converting it back to a stringstruct is a lot of unnecessary work. mail_fetch_structure() avoids all that. Yet another likely mistake is an assumption that a BODY structure from parsing a message is usable for the SMTP routines in sending. It isn't; there are substantial differences between the two. Since I don't know how you purpose to "forward", I don't know what you intend to do with the ENVELOPE and BODY structure. There are undoubtably other mistakes, but you need to clean these up first. I suggest that you take a look at the source for existing applications that use the c-client library, starting with mtest, moving on to mailutil and imapd, and finally to Alpine. There's a lot that you need to learn to do things correctly, and not much in the way of pedagogical documentation. > I get a message attachment, but it has no content. I'm not surprised. -- Mark -- http://staff.washington.edu/mrc Science does not emerge from voting, party politics, or public debate. Si vis pacem, para bellum. |
|
#4
| |||
| |||
| On Fri, 18 Apr 2008, mozuzaeram@gmail.com posted: > I'd like to add that the documentation found in internal.txt is > inaccurate with regards to the BODY structure. internal.txt was written nearly 12 years ago. Quite a bit has changed since then. Most of what is there is still good information as long as you understand that what it documents are the interfaces from 12 years ago. There are substantial extensions, but for the most part the changes are compatible. However, you need to read what is there carefully. A seemingly off-hand comment may be very significant. -- Mark -- http://staff.washington.edu/mrc Science does not emerge from voting, party politics, or public debate. Si vis pacem, para bellum. |
|
#5
| |||
| |||
| On Fri, 18 Apr 2008, mozuzaeram@gmail.com posted: > I have a program that, upon an receiving an email it cannot process, > needs to forward that email to someone with a description of the > error. I hope that you have started on fixing the issues that I indentified for you in your previous message. Now, let's talk about "forwarding" and how to do it properly. There are two types of forwarding: "forwarding" and "resending". [1] Forwarding involves composing a new message with the forwarded message being attached as a MESSAGE/RFC822. You don't need the message ENVELOPE or BODY unless you intend to alter the message when forwarding. Create an ENVELOPE with your ID as the env->from, the destination as the env->to, and the original message header as the env->remail. Create a multipart BODY with a MESSAGE/RFC822 subpart. You may also want a TEXT/PLAIN subpart to carry explanatory text. In the MESSAGE/RFC822 subpart, treat it as if it was TEXT/PLAIN; do *NOT* use any for the cells for encapsulated messages. This is a big difference between BODY structures in messages being read as opposed to messages being composed. [2] Resending (also called "remailing" or "bouncing") involves passing the same message to a new recipient, unmodified except for the addition of ReSent-Date/ReSent-From/ReSent-To headers to indicate the redirection. This is, by far, the easier way to forward in c-client. You don't need the ENVELOPE or BODY at all. All you need is the header and full body text. Create an ENVELOPE with your ID as the env->from, the destination as the env->to, and the original message header as the env->remail. Create a BODY with a single TEXT/PLAIN part, and with its string being the original message full body text. Look at ftp://ftp.cac.washington.edu/mail/ms.tar.Z and the remail_message() routine in it to get a general idea of how to do remailing. -- Mark -- http://panda.com/mrc Democracy is two wolves and a sheep deciding what to eat for lunch. Liberty is a well-armed sheep contesting the vote. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.