Sunday, October 25, 2009

Send email from UNIX | Perl script

This will show you how to send an email from unix server using a perl script.

open (MsgFILE, "> $msgFile");
print MsgFILE "\n I am sending an email to all of you \n";

close(MsgFILE);
print "\n sending mail....\n" if $debug;

open (MAIL,"|(cat $msgFile ; uuencode $file $to_file_name) | mailx -r $from -c $MailCc -s \"$Subject\" $to") or die "Cannot open sendmail: $!";

close MAIL;

No comments: