#!/usr/bin/perl -w use strict; use warnings; use NET::SMTP; my $servername="testserver.com"; my $from="jon@testserver.com"; my $to="jon@testserver.com,ted@testserver.com"; my $subject="test email"; my @body=("testmail"); my $smtp = Net::SMTP->new($servername) || die "unable to connect to server: $servername\n"; die "Could not open connection: $!" if (!defined $smtp); $smtp->mail($from) || die "unable to set sender: $from\n"; $smtp->to($to) || die "unable to set recipient: $to\n"; $smtp->data(); $smtp->datasend("To: $to\n") || die "unable to send data: $to\n"; $smtp->datasend("From: $from\n") || die "unable to send data: $from\n"; $smtp->datasend("Subject: $subject\n")|| die "unable to send data: $subject\n"; $smtp->datasend("\n")|| die "unable to send data: \@body\n"; foreach (@body){ $smtp->datasend("$_\n"); } $smtp->dataend(); $smtp->quit;