[Cascavel-pm] Cliente SMTP

Rafael Lebrao Martins rafamv1 em ig.com.br
Sexta Janeiro 25 06:47:03 PST 2008


Oi, pessoal. Utilizei o módulo SMTP::Lite.. Eu recebo o e-mail, mas o anexo
não..


#!/usr/bin/perl
use warnings;
use strict;
use CGI qw(:standard);
use Net::SMTP_auth;
use Net::SMTP;
use MIME::Lite;

my $hostsmtp='smtp.dominio.com.br';
my $usuario='rafael em dominio.com.br';
my $senha='senha';
my $from='rafael em dominio.com.br';
my $to='rafael em nexoinfo.com.br';
my $mensagem="Teste de envio.";
my $titulo='Backup do MSN Monitor';

my $smtp = Net::SMTP_auth->new("$hostsmtp", Timeout=>60, Debug=>1) || die
("erro: $!\n");

$smtp->auth('PLAIN',$usuario,$senha);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $titulo\n");
$smtp->datasend("Content-type: text/html\n\n");
$smtp->datasend($mensagem);
$smtp->dataend();
$smtp->quit;

my $anexo = MIME::Lite->new ();

$anexo->attach(
Type =>'TEXT');
my $fileName = 'backup.tar.gz';
my $fileType = 'TEXT';
my $file = '/var/log/[arquivo].tar.gz';
$anexo->attach(Type =>$fileType,
Path =>$fileName,
Filename =>$file,
Disposition =>'attachment'
);
$anexo->send();

print "Content-type: text/html\n\n";
print "E-mail enviado!";
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://mail.pm.org/pipermail/cascavel-pm/attachments/20080125/242a6f84/attachment.html 


Mais detalhes sobre a lista de discussão Cascavel-pm