Changeset 6236
- Timestamp:
- 07/31/08 12:39:26 (2 months ago)
- Files:
-
- modules/branches/2.5/core/bin/fax-process.pl (modified) (8 diffs)
- modules/branches/2.5/core/etc/extensions.conf (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/core/bin/fax-process.pl
r5848 r6236 12 12 my $to = "xrobau\@gmail.com"; 13 13 my $from = "fax\@"; 14 my $dest = undef; 14 15 my $subject = "Fax received"; 15 16 my $ct = "application/x-pdf"; … … 26 27 27 28 # Usage: 28 my $usage="Usage: --file filename [--attachment filename] [--to email_address] [--from email_address] [--type content/type] [--subject \"Subject Of Email\"] ";29 my $usage="Usage: --file filename [--attachment filename] [--to email_address] [--from email_address] [--type content/type] [--subject \"Subject Of Email\"] [--dest DID]"; 29 30 30 31 # Parse command line.. … … 54 55 } 55 56 # Convert %2x to proper characters, leave anything else alone. 56 $subject =~ s/\%20/ /g;57 $subject =~ s/\%20/ /g; 57 58 $subject =~ s/\%21/\!/g; 58 59 $subject =~ s/\%22/\"/g; … … 88 89 my $tmp = shift @ARGV; 89 90 $attachment = $tmp if (defined $tmp); 91 } elsif ($cmd eq "--dest") { 92 my $tmp = shift @ARGV; 93 if ($tmp =~ /\^(\")|^(\')/) { 94 # It's a quoted string 95 my $delim = $+; # $+ is 'last match', which is ' or " 96 $tmp =~ s/\Q$delim\E//; # Strip out ' or " 97 $dest = $tmp; 98 while ($tmp = shift @ARGV) { 99 if ($tmp =~ /\Q$delim\E/) { 100 $tmp =~ s/\Q$delim\E//; 101 last; 102 } 103 $dest .= $tmp; 104 } 105 } else { 106 # It's a single word 107 $dest = $tmp; 108 } 90 109 } else { 91 110 die "$cmd not understood\n$usage\n"; … … 103 122 104 123 my $encoded=""; 124 my $enc_gif=""; 105 125 my $buf=""; 126 my $convert_status=0; 127 106 128 # First, lets find out if it's a TIFF file 107 129 read(FILE, $buf, 4); … … 116 138 } 117 139 close PDF; 140 141 open GIF, "convert -resize '50%' -monochrome -delay 300 ${file}[0,1] gif:- |"; 142 if (!eof(GIF)) { 143 $convert_status=1; 144 $buf = ""; 145 while (read(GIF, $buf, 60*57)) { 146 $enc_gif .= encode_base64($buf); 147 } 148 } 149 close GIF; 118 150 } else { 119 151 # It's a PDF already … … 139 171 140 172 my $len = length $encoded; 173 my $len_gif = length $enc_gif; 141 174 # message body.. 142 175 my $msg ="Content-Class: urn:content-classes:message … … 157 190 Content-Transfer-Encoding: quoted-printable 158 191 159 A Fax has been recieved by the fax gateway, and is attached to this message. 160 161 162 --$boundary 192 A Fax has been received by the fax gateway and is attached to this message. 193 194 The destination number for this fax is ".$dest." 195 196 197 "; 198 if ($convert_status eq 1) { 199 $msg=$msg."--$boundary 200 Content-Type: image/gif; name=\"thumb-".substr($attachment,0,-4).".gif\" 201 Content-Transfer-Encoding: base64 202 203 $enc_gif 204 "; 205 } 206 207 $msg=$msg."--$boundary 163 208 Content-Type: $ct; name=\"$attachment\" 164 209 Content-Transfer-Encoding: base64 modules/branches/2.5/core/etc/extensions.conf
r6218 r6236 1099 1099 exten => out_fax,1,txfax(${TXFAX_NAME},caller) 1100 1100 exten => out_fax,2,Hangup 1101 exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} -- subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE});1101 exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --dest "${FROM_DID}" --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE}); 1102 1102 exten => h,2,Hangup() 1103 1103
