update: manda un email con adjuntos usando perl

Monday, January 16th, 2006 @ 6:04 pm | Notas rápidas

### Adjust sender, recipient and your SMTP mailhost
my $from_address = ‘robot@senin.org’;
my $to_address = ‘jorge@senin.com’;
my $mail_host = ‘mail.senin.org”;

my $your_file_txt = ‘for-mail-robot.txt’;

### Adjust subject and body message
my $subject = ‘[notificacion] enviando un email con perl’;
my $message_body = “”;

open ( F , $your_file_txt);
@message_body = <F> ;
close ( F );

### Create the multipart container
$msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>’multipart/mixed’
) or die “Error creating multipart container: $!\n”;
$part->attr(‘content-type.charset’ => ‘UTF8′);

### Add the text message part
$msg->attach (
Type => ‘TEXT’,
Data => $message_body
) or die “Error adding the text message part: $!\n”;

### Add text
$msg->attach (
Type => ‘text/plain’,
Path => $my_file_txt,
Filename => $your_file_txt,
Disposition => ‘attachment’
) or die “Error adding $file_txt: $!\n”;

### Send the Message
MIME::Lite->send(‘smtp’, $mail_host, Timeout=>60);
$msg->send;

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

 

Recently

  • Infección en apps de Android
  • virt-manager: ERROR:root:unsupported locale setting
  • sopastrike.com – Vamos a la huelga
  • No me gusta wordpress
  • [Asterisk] Tareas de mantenimiento
  • screengrab queda muerto
  • rails + omniauth + omniauth-twitter
  • Ruby on Rails + Papercliip: cannot load such file — cocaine (LoadError)
  • `autodetect’: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
  • Drivers nvidia en Debian Wheezy y Xorg con dos monitores ( dual head )
  •