HylaFAX The world's most advanced open source fax server

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

[hylafax-users] faxmail multipart MIME patch



Title: faxmail multipart MIME patch

Hi all,

I've been trying to setup email-to-fax gateway using this software for a while.

While the sendfax portion works great, it took more time to configure faxmail to work properly (especially the attachments - searching the list seems to indicate that this is a common problem around here). Anyway with the help I found in the list archive, I made it to work to handle HTML mail, word, excel, powerpoint, pdf and text files --- that's what I need after all.

During my setup, though, I noticed that faxmail always fails for messages sent by Outlook Express --- it seems to print my HTML mail but ignores the rest of the attachment.

After spending sometime interrogating this, testing & thought experiment, I came to conclusion that there is bug in faxmail that makes it unable to handle nested multipart: once it processes the latest part of the deepest multipart, it ignores the rest of the email.

Apparently this problem is neither recognized, or fixed, or faxmail is not popular since google search on list archives and elsewhere shows nothing about this. So here it is a simple patch to fix the above. It is based on hylafax version 4.3.0. (Note: faxmail.c++ is dated 2003 and MIMEState.c++ is dated 1999 so it may be applicable for even earlier version, but use it at your own risk).

============== Patch for faxmail.c++ ===========
*** hylafax-4.3.0/faxmail/faxmail.c++.james     Fri Nov 21 05:23:15 2003
--- hylafax-4.3.0/faxmail/faxmail.c++   Thu Jun  8 02:29:57 2006
***************
*** 438,447 ****
--- 438,448 ----
   * Format a multi-part part.
   */
  void
  faxMailApp::formatMultipart(FILE* fd, MIMEState& mime, MsgFmt& msg)
  {
+     bool isLastPart = false; //James 7 June 2006
      discardPart(fd, mime);                    // prologue
      if (!mime.isLastPart()) {
        do {
            int c = getc(fd);
            if (c == EOF) {
***************
*** 453,463 ****
            MsgFmt bodyHdrs(msg);               // parse any headers
            bodyHdrs.parseHeaders(fd, mime.lineno);
 
            MIMEState bodyMime(mime);           // state for sub-part
            formatMIME(fd, bodyMime, bodyHdrs);
!       } while (!mime.isLastPart());
      }
  }
 
  /*
   * Format a message part.
--- 454,466 ----
            MsgFmt bodyHdrs(msg);               // parse any headers
            bodyHdrs.parseHeaders(fd, mime.lineno);
 
            MIMEState bodyMime(mime);           // state for sub-part
            formatMIME(fd, bodyMime, bodyHdrs);
!           isLastPart = bodyMime.isLastPart(); //James 7 June 2006
!       } while (!isLastPart);                  //James 7 June 2006
!
      }
  }
 
  /*
   * Format a message part.
=============== end of file ==================


============== Patch for MIMEState.c++ ===========
*** hylafax-4.3.0/faxmail/MIMEState.c++.james   Wed Nov 17 20:23:18 1999
--- hylafax-4.3.0/faxmail/MIMEState.c++ Thu Jun  8 02:31:27 2006
***************
*** 69,79 ****
      lineno = other.lineno;
  }
  MIMEState::~MIMEState()
  {
      if (parent) {
!       parent->lastPart = lastPart;
        parent->lineno = lineno;
      }
  }
 
  void
--- 69,79 ----
      lineno = other.lineno;
  }
  MIMEState::~MIMEState()
  {
      if (parent) {
!       //parent->lastPart = lastPart; //James 7 June 2006
        parent->lineno = lineno;
      }
  }
 
  void
=============== end of file ==============

Hopefully it helps.

cheers,
James Budiono





Project hosted by iFAX Solutions