On April 20, 1999 at 12:51, someone wrote:

> I'm implementing a web based mail server for our internal mail server,
> so that people from outside our organisation are able to access internal
> mails.
> For this I've designed a program which calls POP3 functions at the back
> end. Everything is working fine except for attachment handling.
> So, for this I want to make use of MHonArc utility.
> I went through the code but as it includes numerous modules, its
> becoming difficult for me to pick out the exact code which handles
> just attachments. So, I'ld like your help in this regard.
> To be specific, I just need to know the modules which take a mail body
> and parse the attachments (if any are there), and give back the result
> in html form.

There are several files responsible for converting a message into
HTML.  readmail.pl has the core mail parsing routines and then there
are few other libraries for handling the conversion of various
content-types into HTML.  The MIMEFILTERS resource page lists the
various filter functions.

Note, if all you require is the conversion into HTML functionality,
you can use mhonarc in -single mode.  Example:

    mhonarc -single mesg.822 > mesg.html
    cat mesg.822 | mhonarc -single > mesg.html

You can also embed -single capability into a Perl program.  The
best way depends on your requirements, but the following is a
sample:

    require 'mhamain.pl' || die qq/ERROR: Unable to require "mhamain.pl"\n/;
    mhonarc::initialize();  # only need to call once
    if (!mhonarc::process_input('-single')) {
        ## An error occured.  $mhonarc::ERROR contains the error message
        ## and $mhonarc::CODE contains the status code.  When there is
        ## an error it is non-zero and suitable as an argument to exit().
    }

The mhonarc::process_input() function takes argument just like the
command-line options.  If you want to specify an input file (ie.
do not use standard input) then do something like the following:

    mhonarc::process_input('-single', 'mesg.822');

If input is coming from a filehandle, you can do the following trick:

    open(STDIN, "<&INFILE") || die "Unable to dup filehandle: $!";
    mhonarc::process_input('-single');
    die $mhonarc::ERROR  if $mhonarc::CODE;

If no arguments are passed to mhonarc::process_input(), then
@ARGV is parsed.

        --ewh

----
             Earl Hood              | University of California: Irvine
      [EMAIL PROTECTED]      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME

Reply via email to