#!/usr/bin/perl use MIME::QuotedPrint; use MIME::Base64; # Get environment variable value $home = $ENV{"HOME"}; BEGIN { push @INC, "$home/scripts/Mail" }; use Mail::Sendmail; $receiver = 'myemail@abc.com'; $sender = 'myemail@abc.com'; $subject = 'Test mail'; $message = 'This is a test mail'; $file = 'test.txt'; #mail parameter file $mailfile = 'mailparam.dat'; open (MAILFILE, "$mailfile") || die "Can't open $mailfile for reading: $!\n"; while ( defined ( $_ = ) ) { chomp $_; @mailarray = split(/\|/); $receiver = $mailarray[0]; $sender = $mailarray[1]; $sender = $mailarray[1]; $subject = $mailarray[2]; send_mail($receiver, $sender, $subject, $message, $file); } sub send_mail { my ($receiver, $sender, $subject, $message, $file) = @_; %mail = ( from => "$sender", to => "$receiver", subject => "$subject", ); $boundary = "====" . time() . "===="; $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; $message = encode_qp( $message ); open (F, $file) or die "Cannot read $file: $!"; binmode F; undef $/; binmode F; undef $/; $mail{body} = encode_base64(); close F; $boundary = '--'.$boundary; $mail{body} = <