<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Email to Fax Gateway!</title>
	<atom:link href="http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/</link>
	<description>For linux documentations.</description>
	<lastBuildDate>Wed, 07 Apr 2010 05:43:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Riyesh</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-72</link>
		<dc:creator>Riyesh</dc:creator>
		<pubDate>Mon, 07 Sep 2009 15:20:06 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-72</guid>
		<description>For HTML emails that contain inline graphics 
This is a preprocessor script that will split the email message into parts. These parts include the main html part and any inline graphics. The pyhton module tempfile is used to safely and securely create a temp directory to write all the parts out to. Then html2ps is called to convert the temporary directory to a PS stream that is sent to stdout. Once this work is completed the script removes the temporary directory.

&lt;strong&gt;
#!/usr/bin/python

&quot;&quot;&quot;Unpack a MIME message into a directory of files.&quot;&quot;&quot;

import os
import sys
import email
import mimetypes
import re
import tempfile
import shutil


def main():

    #Get the message from stdin
    fp = sys.stdin.read()

    #Convert this to a message object
    msg = email.message_from_string(fp)

    #Create temp directory to store contents
    tempcon = tempfile.mkdtemp()

    #Change to our tempcon
    os.chdir(tempcon)

    patt1 = re.compile(&#039;&lt;&#039;)
    patt2 = re.compile(&#039;&gt;&#039;)

    for part in msg.walk():
        # multipart/* are just containers
        if part.get_content_maintype() == &#039;multipart&#039;:
            continue
        # Applications should really sanitize the given filename so that an
        # email message can&#039;t be used to overwrite important files
        
        ext = mimetypes.guess_extension(part.get_content_type())
        ctype = part.get(&#039;content-id&#039;)

        if ctype:
           doit = re.sub(patt2, &#039;&#039;, re.sub(patt1, &#039;cid:&#039;, ctype))
        else:
           doit = &#039;main.html&#039;
        
        if not ext:
         # Use a generic bag-of-bits extension
            ext = &#039;.bin&#039;
        fp = open(tempcon + &#039;/&#039; + doit, &#039;wb&#039;)
        fp.write(part.get_payload(decode=True))
        fp.close()
       
    os.system(&#039;/usr/local/bin/html2ps main.html&#039;)
    os.chdir(&#039;..&#039;)
    shutil.rmtree(tempcon)

if __name__ == &#039;__main__&#039;:
    main()
&lt;/strong&gt;


You will likely call the above preprocessor from an initial bash script that is first called from your MTA (ie, sendmail, postfix, etc). For example, my sendmail calls this first script. Note that &#039;multi-write-0.1.py&#039; is the HTML multipart script listed above.

&lt;strong&gt;#!/bin/bash

#/usr/bin/formail -a &#039;X-FAX-Headers: clear&#039; &#124; /usr/local/bin/multi-write-0.1.py &#124; \
/usr/bin/sendfax -n -m -R -f &quot;$2&quot; -d &quot;$1&quot;
&lt;/strong&gt;

Informations copied from hylafax.org website. </description>
		<content:encoded><![CDATA[<p>For HTML emails that contain inline graphics<br />
This is a preprocessor script that will split the email message into parts. These parts include the main html part and any inline graphics. The pyhton module tempfile is used to safely and securely create a temp directory to write all the parts out to. Then html2ps is called to convert the temporary directory to a PS stream that is sent to stdout. Once this work is completed the script removes the temporary directory.</p>
<p><strong><br />
#!/usr/bin/python</p>
<p>&#8220;&#8221;"Unpack a MIME message into a directory of files.&#8221;"&#8221;</p>
<p>import os<br />
import sys<br />
import email<br />
import mimetypes<br />
import re<br />
import tempfile<br />
import shutil</p>
<p>def main():</p>
<p>    #Get the message from stdin<br />
    fp = sys.stdin.read()</p>
<p>    #Convert this to a message object<br />
    msg = email.message_from_string(fp)</p>
<p>    #Create temp directory to store contents<br />
    tempcon = tempfile.mkdtemp()</p>
<p>    #Change to our tempcon<br />
    os.chdir(tempcon)</p>
<p>    patt1 = re.compile(&#8216;< ')<br />
    patt2 = re.compile('>&#8216;)</p>
<p>    for part in msg.walk():<br />
        # multipart/* are just containers<br />
        if part.get_content_maintype() == &#8216;multipart&#8217;:<br />
            continue<br />
        # Applications should really sanitize the given filename so that an<br />
        # email message can&#8217;t be used to overwrite important files</p>
<p>        ext = mimetypes.guess_extension(part.get_content_type())<br />
        ctype = part.get(&#8216;content-id&#8217;)</p>
<p>        if ctype:<br />
           doit = re.sub(patt2, &#8221;, re.sub(patt1, &#8216;cid:&#8217;, ctype))<br />
        else:<br />
           doit = &#8216;main.html&#8217;</p>
<p>        if not ext:<br />
         # Use a generic bag-of-bits extension<br />
            ext = &#8216;.bin&#8217;<br />
        fp = open(tempcon + &#8216;/&#8217; + doit, &#8216;wb&#8217;)<br />
        fp.write(part.get_payload(decode=True))<br />
        fp.close()</p>
<p>    os.system(&#8216;/usr/local/bin/html2ps main.html&#8217;)<br />
    os.chdir(&#8216;..&#8217;)<br />
    shutil.rmtree(tempcon)</p>
<p>if __name__ == &#8216;__main__&#8217;:<br />
    main()<br />
</strong></p>
<p>You will likely call the above preprocessor from an initial bash script that is first called from your MTA (ie, sendmail, postfix, etc). For example, my sendmail calls this first script. Note that &#8216;multi-write-0.1.py&#8217; is the HTML multipart script listed above.</p>
<p><strong>#!/bin/bash</p>
<p>#/usr/bin/formail -a &#8216;X-FAX-Headers: clear&#8217; | /usr/local/bin/multi-write-0.1.py | \<br />
/usr/bin/sendfax -n -m -R -f &#8220;$2&#8243; -d &#8220;$1&#8243;<br />
</strong></p>
<p>Informations copied from hylafax.org website.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hercross</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-71</link>
		<dc:creator>hercross</dc:creator>
		<pubDate>Mon, 07 Sep 2009 06:55:59 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-71</guid>
		<description>In the file, that I activated support, I see:
pdf, ps, PBM, PGM, PPM, txt, GIF, JPEG, FIG, DOC. But I don&#039;t see multi-part.
In what line is it?
Thanks</description>
		<content:encoded><![CDATA[<p>In the file, that I activated support, I see:<br />
pdf, ps, PBM, PGM, PPM, txt, GIF, JPEG, FIG, DOC. But I don&#8217;t see multi-part.<br />
In what line is it?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riyesh</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-69</link>
		<dc:creator>Riyesh</dc:creator>
		<pubDate>Sat, 05 Sep 2009 06:53:33 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-69</guid>
		<description>hi,

for that u have to enable multi-part messages. The same way which u have enabled pdf , doc, support.</description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>for that u have to enable multi-part messages. The same way which u have enabled pdf , doc, support.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hercross</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-67</link>
		<dc:creator>hercross</dc:creator>
		<pubDate>Fri, 04 Sep 2009 06:51:17 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-67</guid>
		<description>Hi, it&#039;s works fine fine.
But one question. If a doc file have an images?
When I try to send, hylafax send the file without images.
Can I do to hylafax send the file with the images?</description>
		<content:encoded><![CDATA[<p>Hi, it&#8217;s works fine fine.<br />
But one question. If a doc file have an images?<br />
When I try to send, hylafax send the file without images.<br />
Can I do to hylafax send the file with the images?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riyesh</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-65</link>
		<dc:creator>Riyesh</dc:creator>
		<pubDate>Tue, 01 Sep 2009 12:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-65</guid>
		<description>&lt;p&gt;Good. Stil you have any doubts... Please use :&quot;chat with admin&quot; on this site..  or click this link http://www.google.com/talk/service/badge/Show?tk=z01q6amlqu5vg7qtpdvoig4abjdmirc3af92vfchak0ckol58vos0i8knbn8n68dp17nod4ucv7g46btrhjq1r1popcmbp35pdqqlqs7qqsv61qbpj21dmkdumomfhcq0h3uhs37qkfsgv5kfo2sqsglbr2o00robdi8psiujj2onr52jr0iq5lvcs150519d7c&amp;w=200&amp;h=60#&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Good. Stil you have any doubts&#8230; Please use :&#8221;chat with admin&#8221; on this site..  or click this link http://www.google.com/talk/service/badge/Show?tk=z01q6amlqu5vg7qtpdvoig4abjdmirc3af92vfchak0ckol58vos0i8knbn8n68dp17nod4ucv7g46btrhjq1r1popcmbp35pdqqlqs7qqsv61qbpj21dmkdumomfhcq0h3uhs37qkfsgv5kfo2sqsglbr2o00robdi8psiujj2onr52jr0iq5lvcs150519d7c&amp;w=200&amp;h=60#</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hercross</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-64</link>
		<dc:creator>hercross</dc:creator>
		<pubDate>Tue, 01 Sep 2009 12:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-64</guid>
		<description>Ahh ok, I have it in /usr/local/lib/fax/typerules.
I&#039;ve probe .doc and its ok, now jpeg, html,.....
Thanksd</description>
		<content:encoded><![CDATA[<p>Ahh ok, I have it in /usr/local/lib/fax/typerules.<br />
I&#8217;ve probe .doc and its ok, now jpeg, html,&#8230;..<br />
Thanksd</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riyesh</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-63</link>
		<dc:creator>Riyesh</dc:creator>
		<pubDate>Tue, 01 Sep 2009 12:06:43 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-63</guid>
		<description>&lt;p&gt;upgrade your hylafax version&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>upgrade your hylafax version</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hercross</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-62</link>
		<dc:creator>hercross</dc:creator>
		<pubDate>Tue, 01 Sep 2009 12:01:18 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-62</guid>
		<description>Sorry for two same post, I have a problem.....
The file typerules, I have it in var/spool/hylafax/etc/typerules, and I don&#039;t see that section.
I&#039;ve instaled hylafax +, could be for that?
Thanks</description>
		<content:encoded><![CDATA[<p>Sorry for two same post, I have a problem&#8230;..<br />
The file typerules, I have it in var/spool/hylafax/etc/typerules, and I don&#8217;t see that section.<br />
I&#8217;ve instaled hylafax +, could be for that?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hercross</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-61</link>
		<dc:creator>hercross</dc:creator>
		<pubDate>Tue, 01 Sep 2009 11:57:10 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-61</guid>
		<description>Yes I installed it.  But when i try to send it, I see that.</description>
		<content:encoded><![CDATA[<p>Yes I installed it.  But when i try to send it, I see that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riyesh</title>
		<link>http://linuxbuddies.com/2009/01/04/email-to-fax-gateway/comment-page-1/#comment-59</link>
		<dc:creator>Riyesh</dc:creator>
		<pubDate>Tue, 01 Sep 2009 11:39:40 +0000</pubDate>
		<guid isPermaLink="false">http://linuxbuddies.com/?p=257#comment-59</guid>
		<description>&lt;p&gt;did you installed antiword ? for msword support&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>did you installed antiword ? for msword support</p>
]]></content:encoded>
	</item>
</channel>
</rss>
