#!/usr/local/bin/perl -w
# Send message with attachments
# Instaill Perl Module
# perl -MCPAN -e shell
# Terminal does not support AddHistory.
# cpan shell -- CPAN exploration and modules installation (v1.7602)
# ReadLine support available (try 'install Bundle::CPAN')
# cpan> install Time::Format
use MIME::Lite;
use Time::Format;
$yt = $time{'yyyymmdd'};
$TXTFILE="/root/$yt-checkmtree.txt";
#$ATTFILE="/root/mtree2.txt";
$SUBJECT="Mtree Check Out ";
$MAILTO="dengxb\@kevinagios.com";
# Create a new multipart message:
$msg = new MIME::Lite
From => "$ENV{LOGNAME}",
To => "$MAILTO",
Subject => "$SUBJECT",
Type => 'multipart/mixed';
# Add parts (each "attach" has same arguments as "new"):
attach $msg
Type => 'text/plain',
Path => "$TXTFILE";
#attach $msg
# Type => 'application/octet-stream',
# Encoding => 'base64',
# Path => "/tmp/$ATTFILE",
# Filename => "$ATTFILE";
# Output the message to sendmail
open (SENDMAIL, "| /usr/sbin/sendmail -t -oi");
$msg->print(\*SENDMAIL);
close(SENDMAIL);
阅读(1489) | 评论(0) | 转发(0) |