***** infoCopter.com/perl *****
Portable Version of Sending Mail without sendmailFAQ's & AnswersVery flexible version. Runs on Windows and Unix.
#!/usr/local/bin/perl -w
use strict;
use Net::SMTP;
use Net::Config;
my $smtp_host = (@{$NetConfig{smtp_hosts}})[0];
print "$smtp_host\n";
# $smtp_host = "mail.bluewin.ch";
my $smtp = Net::SMTP->new($smtp_host, Debug => 0) or die "Could not create object";
sendmail(to => "you\@domain.ch", subject => 'test', msg => "Hello!\n");
sendmail(to => "another\@domain.com", subject => '2nd test', msg => "Hello again!\n");
$smtp->quit;
sub sendmail(@) {
my %args = @_;
# return path
$smtp->mail('spam@insign.ch');
$smtp->to($args{'to'});
# mail message body
$smtp->data();
$smtp->datasend("From: you\@yourdomain.ch\n");
$smtp->datasend("To: friends_of_quasimodo\@yourdomain.ch\n");
$smtp->datasend("Subject: $args{'subject'}\n\n");
$smtp->datasend($args{'msg'});
$smtp->datasend("----- END OF MAIL -----\n");
$smtp->dataend() or die "Could not send";
}
|