#!/usr/bin/perl
use strict;
use warnings;
use Net::SMTP;
use Getopt::Long;
my $from = '' || 'system@server1.com' ;
my $sub = '' || 'this is a testmail';
my $content = '' || 'this is a data';
my $to;
my $relayhost = '' || 'localhost';
GetOptions(
'from|f=s' => \$from ,
'to|t=s' => \$to,
'sub|s=s' => \$sub ,
'content|c=s' => \$content,
'relayhost|h=s' => \$relayhost );
die 'usage: sendmemail.pl--to name@email.com' unless( $to );
my $smtp = Net::SMTP->new("$relayhost",
Debug => 1,
);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("Subject: $sub");
$smtp->datasend("\n");
$smtp->datasend("\n");
$smtp->datasend("$content");
$smtp->dataend();
$smtp->quit();
No comments:
Post a Comment