File: GenerateFileMail.pl

package info (click to toggle)
capi4hylafax 1:01.03.00.99.svn.300-16
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,044 kB
  • ctags: 3,085
  • sloc: cpp: 20,823; sh: 9,412; makefile: 226; perl: 36
file content (55 lines) | stat: -rwxr-xr-x 1,162 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /usr/bin/perl -w
#
# This Script is called by sample_faxrcvd to generate
# a mail with an attached file.
#
# It's based on the hylafax-sample from
# Noel Burton-Krahn <noel@burton-krahn.com>
# (see www.hylafax.org / howto)
#
use strict;
my($fromaddr, $toaddr, $subject, $text, $textdesc, $file, $filemime, $virtfilename, $filedesc) = @ARGV;
my($boundary);

$boundary=join('---',
	       "=Boundary=",
	       $$,
	       sprintf('%x', rand(0xffffffff)));

print <<EOF
From: $fromaddr
To: $toaddr
Subject: $subject
Mime-Version: 1.0
Content-Type: Multipart/Mixed; Boundary=\"$boundary\"
Content-Transfer-Encoding: 7bit

This is a multi-part message in MIME format.

--$boundary
Content-Type: text/plain; charset=us-ascii
Content-Description: $textdesc
Content-Transfer-Encoding: 7bit

$text


EOF
;
print <<EOF
--$boundary
Content-Type: $filemime; name="$virtfilename"
Content-Description: $filedesc
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$virtfilename"

EOF
;

open(IN, "mimencode \"$file\" |") || die ("couldn't mimencode $file: $!");
print while(<IN>);
close(IN) || die("mimencode: $?");

print <<EOF
--$boundary--
EOF