use strict; use warnings; use Mail::Sendmail; use MIME::QuotedPrint; use MIME::Base64; my $file1 = 'c:\test1.xls'; my $file2 = 'c:\sample.zip'; my $file3 = $file2 || $file1; # file to attach my %mail = ( To => "abc@yahoo.com", From => "def@yahoo.com", Cc => "hij@yahoo.com", Subject => "Two Attachments", smtp => 'mac.abc.com' ); my $content; { local $/ = undef; # slurp file open IN, $file3 or die "Error opening $file3: $!"; binmode IN; $content = ; $mail{body} += encode_base64(); close IN; } my $boundary = "====" . time() . "===="; $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; my $message = encode_qp( $email_body ); my $len = length $$mail{body}; $mail{body} = <>$sendmail_log") or die "Cannot open LOG file $file3: $!"; print OUT $Mail::Sendmail::log; print OUT "\n==============================================================================\n"; close(OUT);