Mercurial > laserkard
diff 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 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/megamail.pl Sun Jan 24 09:37:47 2010 -0500 1.3 @@ -0,0 +1,56 @@ 1.4 +use MIME::QuotedPrint; 1.5 +use MIME::Base64; 1.6 +use Mail::Sendmail 0.75; # doesn't work with v. 0.74! 1.7 + 1.8 +%mail = ( 1.9 + from => 'rlm@mit.edu', 1.10 + to => 'rlm@mit.edu', 1.11 + subject => 'Test attachment', 1.12 + ); 1.13 + 1.14 + 1.15 +$boundary = "====" . time() . "===="; 1.16 +$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; 1.17 + 1.18 +$message = encode_qp( "email from your friend PERL." ); 1.19 + 1.20 +$file = "./inkscape/arrow.svg"; 1.21 + 1.22 +open (F, $file) or die "Cannot read $file: $!"; 1.23 +binmode F; undef $/; 1.24 +$attach1 = encode_base64(<F>); 1.25 +close F; 1.26 + 1.27 + 1.28 + 1.29 +$attach2 = encode_base64("hi this is a test arttacghjkalsdlasndlashdlsf"); 1.30 + 1.31 + 1.32 + 1.33 + 1.34 + 1.35 +$boundary = '--'.$boundary; 1.36 +$mail{body} = <<END_OF_BODY; 1.37 +$boundary 1.38 +Content-Type: text/plain; charset="iso-8859-1" 1.39 +Content-Transfer-Encoding: quoted-printable 1.40 + 1.41 +$message 1.42 +$boundary 1.43 +Content-Type: application/octet-stream; name="test.svg" 1.44 +Content-Transfer-Encoding: base64 1.45 +Content-Disposition: attachment; filename="test.svg" 1.46 + 1.47 +$attach1 1.48 + 1.49 +$boundary 1.50 +Content-Type: application/octet-stream; name="huh.txt" 1.51 +Content-Transfer-Encoding: base64 1.52 +Content-Disposition: attachment; filename="huh.txt" 1.53 + 1.54 +$attach2 1.55 +$boundary-- 1.56 + 1.57 +END_OF_BODY 1.58 + 1.59 +sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";