вторник, 7 апреля 2009 г.

Отправляем письмо из perl

Собираем\устанавливаем модуль:

Port: p5-Mail-Tools-2.04
Path: /usr/ports/mail/p5-Mail-Tools
Info: Perl5 modules for dealing with Internet e-mail messages
Maint: kuriyama@FreeBSD.org
B-deps: perl-5.8.9_2
R-deps: p5-TimeDate-1.16,1 perl-5.8.9_2
WWW: http://search.cpan.org/dist/MailTools

##
#!/usr/bin/perl

use Mail::Mailer;


my $from_address = "angel\@from_domain.ru";
my $to_address = "destination\@to_domain.ru";
my $subject = "Новое отправленное письмо";

my $mailer = Mail::Mailer->new();
# my $mailer = new Mail::Mailer 'smtp', Server=>'SERVERNAME';

$mailer->open({ 'Content-Type' => 'text/plain; charset=KOI8-R',
From => $from_address,
To => $to_address,
Subject => $subject,
}) or die "Can't create object Mail::Mailer: $!\n";
my $mail_body = "Вот я с помощью perl отправила письмо на любой адрес :)

--
Sincerely yours,
Auto generation script
";

print $mailer $mail_body;

$mailer->close();

##

Комментариев нет: