/usr/lib/sendmail -oi -t
From: linux
To: root
Subject: Sub
#one space is required after subject and then the body begins
Test body
pico sendmail1.pl
#!/usr/bin/perl -w
$MAIL = "SENDMAIL";#file handle that redirects to a pipe everything
open ($MAIL, "| /usr/lib/sendmail -oi -t") || die "Errors with sendmail $!";#we open a pipe
print $MAIL <<"EOF";
From: Mark
To: root
Subject: testing mail from perl
Testing body of message
EOF
close ($MAIL);
#end
mutt - see mails
#!/usr/bin/perl -w
$MAIL = "SENDMAIL";#file handle that redirects with the help of a pipe everything to sendmail
open ($MAIL, "| /usr/lib/sendmail -oi -t") || die "Errors with sendmail $!";#we open a pipe
print $MAIL <<"EOF";
$BODY="Directory listing";
@dirlist=`ls -Al`
From: Mark
To: root
Subject: testing mail from perl
$BODY
@dirlist
EOF
close ($MAIL);
#end
perl -MMail::Mailer -e 1#query the local perl distribution on your computer to see if that module is installed on your computer. If the module is installed the result is 0.
perl -MCPAN -e "install Mail::Mailer" # install a module in perl
sendmail2.pl
#!/usr/bin/perl -w
use Mail::Mailer
$from = "root";
$to = "root";
$subject = "subject";
$BODY="Directory listing";
$mailer = Mail::Mailer->new();
$mailer->open({From => $from,
To => $to,
Subject => $subject,
});
print $mailer $BODY;
#end
ssh -l user localhost
No comments:
Post a Comment