Perl SMTP
2003-01-26 23:21:42
Category: perl:internet
Description: Send an email using Net::SMTP to communicate with a SMTP server.
Author: detour
Viewed: 13864
Rating: (94 votes)


#!/usr/bin/perl
#
# net-smtp.pl by detour@metalshell.com
#
# Send an email using Net::SMTP to communicate to a SMTP server.
#
# http://www.metalshell.com
#
 
use Net::SMTP;
 
$from = 'your@localemail.com';
$to = 'someone@else.com';
$subject = 'Test Email';
 
$smtp = Net::SMTP->new('localhost');
 
$smtp->mail($from);
$smtp->to($to);
 
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("Testy\n\n-bye");
$smtp->dataend();
 
$smtp->quit;