comparison megamail.pl @ 37:021a9ab1ed5b laserkard

[svn r38] added echo.pl, a test program for the backend of the website
author rlm
date Sun, 24 Jan 2010 09:37:47 -0500
parents
children
comparison
equal deleted inserted replaced
36:bb048e29406b 37:021a9ab1ed5b
1 use MIME::QuotedPrint;
2 use MIME::Base64;
3 use Mail::Sendmail 0.75; # doesn't work with v. 0.74!
4
5 %mail = (
6 from => 'rlm@mit.edu',
7 to => 'rlm@mit.edu',
8 subject => 'Test attachment',
9 );
10
11
12 $boundary = "====" . time() . "====";
13 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
14
15 $message = encode_qp( "email from your friend PERL." );
16
17 $file = "./inkscape/arrow.svg";
18
19 open (F, $file) or die "Cannot read $file: $!";
20 binmode F; undef $/;
21 $attach1 = encode_base64(<F>);
22 close F;
23
24
25
26 $attach2 = encode_base64("hi this is a test arttacghjkalsdlasndlashdlsf");
27
28
29
30
31
32 $boundary = '--'.$boundary;
33 $mail{body} = <<END_OF_BODY;
34 $boundary
35 Content-Type: text/plain; charset="iso-8859-1"
36 Content-Transfer-Encoding: quoted-printable
37
38 $message
39 $boundary
40 Content-Type: application/octet-stream; name="test.svg"
41 Content-Transfer-Encoding: base64
42 Content-Disposition: attachment; filename="test.svg"
43
44 $attach1
45
46 $boundary
47 Content-Type: application/octet-stream; name="huh.txt"
48 Content-Transfer-Encoding: base64
49 Content-Disposition: attachment; filename="huh.txt"
50
51 $attach2
52 $boundary--
53
54 END_OF_BODY
55
56 sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";