I posted my fetch-n-fax script at https://github.com/billsimon/asterisk-fetch-n-fax
You can use it as-is by putting it in the asterisk user's crontab however often you want to fetch. (Every 5 minutes, for example.) This uses Asterisk's fax module (spandsp), so you would have to modify the sendFax() function or write a new one if you want to use Hylafax instead.
In short, it opens an IMAP (GMail) account and retrieves all unread messages. It takes the destination from the subject line (no error checking) and pulls PDFs out of the body. It converts the PDF(s) to TIFF and faxes them to the destination. Lastly it sends a notice to the sender to say that the fax was processed but there's no status handling here. The fax is left in the IMAP store as a read message so you can go and review later what was sent. If one of the faxes didn't work, just set the message to unread and it will be tried again.
TO DO ... validation of the subject line (destination), clean-up of the TIFFs that are left behind in /tmp, proper status checking and reporting... but here's a starting point for you.
You can use it as-is by putting it in the asterisk user's crontab however often you want to fetch. (Every 5 minutes, for example.) This uses Asterisk's fax module (spandsp), so you would have to modify the sendFax() function or write a new one if you want to use Hylafax instead.
In short, it opens an IMAP (GMail) account and retrieves all unread messages. It takes the destination from the subject line (no error checking) and pulls PDFs out of the body. It converts the PDF(s) to TIFF and faxes them to the destination. Lastly it sends a notice to the sender to say that the fax was processed but there's no status handling here. The fax is left in the IMAP store as a read message so you can go and review later what was sent. If one of the faxes didn't work, just set the message to unread and it will be tried again.
TO DO ... validation of the subject line (destination), clean-up of the TIFFs that are left behind in /tmp, proper status checking and reporting... but here's a starting point for you.