-
-
Save stefb69/ab1bbb39453d37d54eb4 to your computer and use it in GitHub Desktop.
| #!/bin/sh | |
| # mail2fax reloaded | |
| # modified version working 100% by stefb (for europe) | |
| # This script allows you to send faxes through your HylaFAX box. | |
| # It uses mpack to strip out email attachments and sendfax to do | |
| # the fax delivery. | |
| ### Temporary dir stuff | |
| RANDOMFAX=/tmp/faxtmp.$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ") | |
| if [ ! -d "$RANDOMFAX" ] ; then | |
| mkdir $RANDOMFAX | |
| fi | |
| rm -f $RANDOMFAX/* | |
| ### Some makeup (maybe not necessary anymore) | |
| sed 's/multipart\/alternative/multipart\/mixed/' > $RANDOMFAX/_message_ | |
| JOBID=`grep -e "^subject:" -i $RANDOMFAX/_message_ | sed q | sed 's/^[^:]*: *//g'` | |
| TOLINE=`grep -e "^to:" -i $RANDOMFAX/_message_ | sed q` | |
| FROMLINE=`grep -e "^from:" -i $RANDOMFAX/_message_ | sed q` | |
| if [ "`echo $TOLINE | grep '<.*>'`" != "" ]; then | |
| TONUMBER=`echo $TOLINE| sed -e 's/.*<\(.*[^@]*\)@.*>.*/\1/'` | |
| else | |
| TONUMBER=`echo $TOLINE| sed -e 's/^[Tt]o://g' -e 's/[ ]*\(.*[^@]*\)@.*/\1/'` | |
| fi | |
| if [ "`echo $FROMLINE | grep '<.*>'`" != "" ]; then | |
| FROMPATH=`echo $FROMLINE| sed -e 's/.*<\(.*\).*>.*/\1/'` | |
| else | |
| FROMPATH=`echo $FROMLINE| sed -e 's/^[Ff]rom://g' -e 's/[ ]*\([^ ]*\).*/\1/'` | |
| fi | |
| ### Split message | |
| munpack -q -C $RANDOMFAX _message_ > /dev/null 2>&1 | |
| ### Delete all but the attachments | |
| rm -f $RANDOMFAX/_message_ | |
| rm -f $RANDOMFAX/*.desc | |
| ### Delivery time! | |
| echo sendfax -R -f "$FROMPATH" -s a4 -n -d "$TONUMBER" $RANDOMFAX/* >> /tmp/faxlog | |
| sendfax -R -f "$FROMPATH" -s a4 -n -d "$TONUMBER" $RANDOMFAX/* | |
| ### Remove temporary dir | |
| rm -rf $RANDOMFAX |
Great, thank's a lot worked of the shell. Please be reminded to install mpack
I recently needed a way to send faxes quickly without dealing with outdated machines or complicated setups, and experimenting with a Mail to Fax gateway script made a huge difference. What struck me was how seamless the integration can be—once you set up the script, sending a fax directly from an email feels just like sending a regular message, but with all the formatting intact. I combined this with a service like https://mfax.to/, which simplifies sending from any device—phone, tablet, or computer—while keeping everything secure and HIPAA-compliant. It handles multiple file types, lets you scan or sign documents on the fly, and the delivery is almost instant. For anyone who needs reliable, paperless faxing, this combination made the process fast, predictable, and surprisingly stress-free.
hi there, im using this script in my hylafax + postfix. When im trying to send email to fax (using thunderbird) , it didnt show any JID on my faxstat, its like not working for me at all... and when im using the original version which was written by Lee. It could send mail to fax but what i got there at the another side (fax machine) only bunch of logs, my sent contents were gone.