Debian Codegraph @

faxmail/mailfax.sh-postfix

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/bin/sh
2 #
3 # mailfax - email to fax gateway for Postfix.
4 #
5 # Here you find instructions about 2 email-to-fax configurations
6 # using HylaFAX and Postfix, they differ in the email address format:
7 #
8 # 1. <username>@<fax-no>.fax ('classic' HylaFAX email-to-fax setup)
9 #
10 # 2. <fax-no>@fax.yourdomain.dom
11 #
12 # GENERAL NOTES:
13 # - Linux binary/config files locations assumed, change them to suit your
14 # system conventions.
15 # - Setup #1 requires you install this file as /usr/bin/mailfax, while
16 # setup #2 does not.
17 # - Whatever setup you chose, when finished you need to run
18 # # postmap /etc/postfix/transport
19 # # postfix reload
20 # in order for the changes to take effect immediately
21 #
22 ##################################################
23 #
24 # 1. <username>@<fax-no>.fax ('classic' HylaFAX email-to-fax setup)
25 #
26 # *** you NEED TO INSTALL this file as /usr/bin/mailfax ***
27 #
28 # Add the following to /etc/postfix/master.cf:
29 # fax unix - n n - 1 pipe
30 # flags= user=fax argv=/usr/bin/mailfax ${user} ${recipient} ${sender}
31 #
32 # Add the following to /etc/postfix/transport:
33 # .fax fax:localhost
34 #
35 # Add the following to /etc/postfix/main.cf:
36 # transport_maps = hash:/etc/postfix/transport
37 # fax_destination_recipient_limit = 1
38 #
39 #
40 # Notes:
41 # 1) If you want the fax to be submitted as an user other than fax (uucp),
42 # then replace
43 # flags= user=fax argv=/usr/bin/mailfax ${user} ${recipient} ${sender}
44 # with
45 # flags= user=<anyuser> argv=/usr/bin/mailfax ${user} ${recipient} ${sender}
46 # Do not use 'root' ...
47 # 2) If you want the HylaFAX email contact to be the same for all the fax
48 # submitted via email, then replace
49 # flags= user=fax argv=/usr/bin/mailfax ${user} ${recipient} ${sender}
50 # with
51 # flags= user=fax argv=/usr/bin/mailfax ${user} ${recipient} <some@address>
52 #
53 ##################################################
54 #
55 # 2. <fax-no>@fax.yourdomain.dom
56 #
57 # *** you _DO_ _NOT_ NEED TO INSTALL this file as /usr/bin/mailfax ***
58 #
59 # See http://www.postfix.org/faq.html#fax for instructions on how to set up
60 # an email-to-fax gateway with this email address format.
61 #
62 # For your convenience the faq available at the above URL is reproduced here.
63 #
64 # ===== http://www.postfix.org/faq.html#fax (as of 2001-03-05)
65 # Sending mail to a FAX machine
66 #
67 # The following information is by Joerg Henne:
68 #
69 # Over here we are using the scheme <fax number>@fax.our.domain
70 # with Postfix and HylaFax. Here's the setup used:
71 #
72 # /etc/postfix/master.cf:
73 # fax unix - n n - 1 pipe
74 # flags= user=fax argv=/usr/bin/faxmail -d -n ${user}
75 #
76 # /etc/postfix/transport:
77 # fax.your.domain fax:localhost
78 #
79 # /etc/postfix/main.cf:
80 # transport_maps = hash:/etc/postfix/transport
81 # fax_destination_recipient_limit = 1
82 #
83 # The process limit of 1 in the master.cf file is necessary with fax software
84 # that cannot handle multiple requests at the same time.
85 # It won't hurt otherwise.
86 #
87 # The fax_destination_recipient_limit entry (by Simon, Mr.Simix)
88 # is necessary with fax software that can't have more than one destination
89 # on its command line. It won't hurt otherwise.
90 #
91 # Specify dbm instead of hash if your system uses dbm files instead of
92 # db files. To find out what map types Postfix supports, use the command
93 # postconf -m.
94 #
95 # Note: be sure to not advertise fax.your.domain in the DNS :-)
96 #
97 # =====
98 #
99 # Notes:
100 # 1) If you want the fax to be submitted as an user other than fax (uucp),
101 # then replace
102 # flags= user=fax argv=/usr/bin/faxmail -d -n ${user}
103 # with
104 # flags= user=<anyuser> argv=/usr/bin/faxmail -d -n ${user}
105 # Do not use 'root' ...
106 # 2) faxmail automatically gets the 'from' identity (to be used for email
107 # notifications by HylaFAX) from the email headers; should you find the
108 # address is not detected correctly you can try replacing
109 # flags= user=fax argv=/usr/bin/faxmail -d -n ${user}
110 # with
111 # flags= user=fax argv=/usr/bin/faxmail -d -n ${user} ${sender}
112 # If you want the email contact to be the same for all the fax submitted
113 # via email, then use
114 # flags= user=fax argv=/usr/bin/faxmail -d -n ${user} <some@address>
115 #
116 ##################################################
117 USER=$1
118 RECIPIENT=$2
119 SENDER=$3
120
121 TMPVAR=${USER//\`/}
122 TMPVAR=${TMPVAR//\$\(/}
123 USER=${TMPVAR//\)/}
124
125 TMPVAR=${RECIPIENT//\`/}
126 TMPVAR=${TMPVAR//\$\(/}
127 RECIPIENT=${TMPVAR//\)/}
128
129 TMPVAR=${SENDER//\`/}
130 TMPVAR=${TMPVAR//\$\(/}
131 SENDER=${TMPVAR//\)/}
132
133 # Try the commented out command if this does not work...
134 FAXNO=`/usr/bin/expr "$RECIPIENT" : '.*@\(.*\)\.fax$'`
135 #FAXNO=`/usr/bin/expr \"$RECIPIENT\" : '.*@\(.*\)\.fax$'`
136
137 /usr/bin/faxmail -n -d "${USER}@${FAXNO}" ${SENDER}
138