email to fax

Status
Not open for further replies.

Ricky

New Member
Feb 14, 2017
16
2
3
53
First you will need to enable the email settings under Advanced > Default Settings then Email.
Once you have done that go to Apps > Email Server give it a Name, Extension, Email, Caller ID Name and Caller ID Number.
Then go to Dialplan > Destination, Create a new Inbound destination. Set Destination number, Action: point to Fax Server Extension then Fax Detection.
that's it you should be good to go.
 
  • Like
Reactions: yhbilisim

yhbilisim

New Member
Feb 13, 2017
28
1
3
32
First you will need to enable the email settings under Advanced > Default Settings then Email.
Once you have done that go to Apps > Email Server give it a Name, Extension, Email, Caller ID Name and Caller ID Number.
Then go to Dialplan > Destination, Create a new Inbound destination. Set Destination number, Action: point to Fax Server Extension then Fax Detection.
that's it you should be good to go.



Hello there
First of all, thank you for helping me.

I want information for email to fax.
Fax to email No problem.
In short, I would like to know the email-to-fax settings in the advanced options on the fax server and how to use the fax via mail.
 

Harald Gutmann

New Member
Mar 1, 2017
6
0
1
36
This is a tricky thing, and can get very complex quite fast.

What I've done is the following:
Setup a mail and imap server (used Postfix & Dovecot).
Joined Postfix & Dovecot to have use the same auth data.
Connected Dovecot to FusionPBX PGSQL DB for authentication usernames/passwords.

Trigger send_fax.php or something like that when a mail hits "phone-number@fax".
Deflect the sent mail to be forwarded to the a specific inbox folder of the same user.
And have FusionPBX check the mails from there for E-Mail to Fax.

This is the short recall summary of our implementation on mail2fax. Complex, but OOTB without any other mail provider required. Fax is done directly into the network via ISDN SIP Gateway. Using T38 to transfer the fax to the Gateway, and the mechanisms of the corresponding freeswitch module. Any SIP extension user/password can authenticate with the mail server, and Fax2Mail hits the same Inbox.
 

william wu

New Member
May 16, 2017
1
0
1
46
Hi Harald, can you provide any code sample on sending fax once email is received on the box?
 

Harald Gutmann

New Member
Mar 1, 2017
6
0
1
36
Hello william wu,

sorry for the delayed reply. Here are some snippets on how I've implemented that feature. But as it is a complex setup, it will not work with copy & paste, the information provided will be guideline and the shows the parts related to FusionPBX and the triggers in the MTA.

Postfix:
/etc/postfix/main.cf
Code:
transport_maps = pcre:/etc/postfix/transport_maps.pcre
mailtofax_destination_recipient_limit = 1

/etc/postfix/transport_maps.pcre
Code:
/^\d{3}\d+@fax.*/       mailtofax

/etc/postfix/master.cf
Code:
mailtofax unix -        n       n       -       2       pipe
  flags= user=vmail:www-data argv=/usr/local/bin/mailtofax.sh  ${mailbox} ${sender}

/usr/local/bin/mailtofax.sh
Code:
#!/bin/sh

set -x

LOGFILE=/tmp/mailtofax_$(date +'%Y%m%d_%H%M%S')_$$.log

echo -n "faxmail was called: " > ${LOGFILE}
echo "date: $(date +'%Y/%m/%d %H:%M:%S'); pid: $$" >> ${LOGFILE}
echo "Phone Nr.: ${1}," "Sender: ${2}" >> ${LOGFILE}

#Modify Subject to contain the [Fax] tag & Phone Nr.
sed -e "s/Subject:/Subject: [Fax][${1}] /" <&0 | /usr/sbin/sendmail <&0 ${2}

echo "exit status sendmail: $? \n" >> ${LOGFILE}

if echo $? ; then
        echo "Calling /var/www/fusionpbx/app/fax/fax_emails.php:" >> ${LOGFILE}
        /usr/bin/php /var/www/fusionpbx/app/fax/fax_emails.php 2>&1 >> ${LOGFILE}
        echo "\n/var/www/fusionpbx/app/fax/fax_emails.php finished." >> ${LOGFILE}
fi
root

Just to give you a rough overview what will happen there with the above config:
Any mail reaching the postfix MTA with a delivery address of "3 or more numerical digits"@fax will be handled by the mailtofax transport. The transport is effectively a script which is called with $mailbox and $sender as argument.

And that transport does not much in this setup. It just adds [FAX][fax-number] to the Subject and sends it via sendmail back to the $sender. Further the FusionPBX provided fax_emails.php is called. This php script then checks the configured mailboxes for new faxes and picks up the fax into the FusionPBX fax sending queue.

The flow of the email is:
sender -> fax-number@fax (only numerical digits allowed, submitted via smtp to postfix)
postfix -> mailtofax.sh -> sender (submitted via localhost)
postfix receives the new mail with the updated subject directed to the sender itself

That's where dovecot comes into action with a Sieve filter & a hidden Fax directory in the users mailbox:
/etc/dovecot/conf.d/90-sieve.conf
Code:
sieve_default = /var/lib/dovecot/sieve/default.sieve

/var/lib/dovecot/sieve/default.sieve
Code:
require ["fileinto"];

if address :contains "to" "@fax" {
  fileinto "Fax";
}

FusionPBX is configured at the web-interface to connect to dovecot via IMAP & look into the folder FAX for new faxes, with the prefix [FAX] [FAX-Number]. fax_emails.php triggers FusionPBX to do that lookup and the sending of the fax.

Postfix is configured to do a SASL auth with Dovecot, mailboxes are virtual mailboxes, and Dovecot gets the user data from the FusionPBX database.
conf.d/auth-sql.conf.ext
Code:
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext

/etc/dovecot/dovecot-sql.conf.ext
Code:
driver = pgsql
connect = host=localhost dbname=fusionpbx user=fusionpbx password='database-password'

default_pass_scheme = PLAIN

password_query = SELECT extension AS user, password \
   FROM v_extensions WHERE extension = '%n';

user_query = SELECT '/var/vmail/%n' AS home, 'vmail' AS gid, \
   'vmail' AS uid FROM v_extensions WHERE extension = '%n';

With that SQL connection, any extension configured in FusionPBX can connect to the SMTP server with the username = extension & password = extension_password.
In this case a quick-setup-standalone PBX with mail2fax available was the goal, no user scheme integration required. The mail2fax sender has to setup a dedicated e-mail account for faxing on his client device.

Strongly depending on what your goal is, it might be a complete nonsense to do that SQL connection in the described way.


I hope that you could get some idea on how to eventually handle mail2fax in connection with FusionPBX. Mailing is a complex topic, and has a lot of additional configuration which have not been outlined here.


Best regards,
Harald
 

amals257

New Member
Apr 6, 2020
6
0
1
34
put cron

* * * * * php /var/www/fusionpbx/app/fax/fax_emails.php

then

configure IMAP settings in fax server > advanced settings

then

configure email subject tag

then

configure authorized senders

then

SHOOT EMAIL to FAX
 
Status
Not open for further replies.