#!/usr/bin/perl
#use Net::SMTP;
use Net::SMTP_auth;
use MIME::Lite;
use Encode;
my $mailhost = "mail.server.com"; # the smtp host
my $mailfrom = 'your.name@server.com'; # your email address
my @mailto = ('your.friend@server.com'); # the recipient list
my $subject = "type subject here";
my $text = "type letter content here.";
$smtp = Net::SMTP_auth->new($mailhost, Hello => $mailhost, Timeout => 120, Debug => 1);
# anth login, type your user name and password here
$smtp->auth('LOGIN','your.name@server.com','password');#LOGIN
foreach my $mailto (@mailto) {
# Send the From and Recipient for the mail servers that require it
my $msg = MIME::Lite->new(
From => $mailfrom,
To => $mailto,
Subject => $subject,
Type => 'multipart/mixed',
);
$msg->attach(Type =>'TEXT',
Data => $text,
);
$msg->attach(Type=>'AUTO',
Path => 'the path to attachment',
);
my $str=$msg->as_string();
$smtp->mail($mailfrom);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("$str");
$smtp->dataend();
}
$smtp->quit;

No comments:
Post a Comment