Click here to get back home

How to log the output of Mime::Lite ?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How to log the output of Mime::Lite ? kenhensleys 06-26-2006
Posted by kenhensleys on June 26, 2006, 6:52 pm
Please log in for more thread options


I have this simple Mime::Lite script quoted below.
It works alright.
But I would like to trace the result of the output.
Something like
set -x in ksh
or anything else similar.
Or some logging?
What should I do and where should I put it?

.....................

#!/usr/bin/perl

use MIME::Lite;
use Net::SMTP;

my $from_address = j...@yahoo.com';
my $to_address = 'sm...@yahoo.com';
my $mail_host = 'mailhost.domain.com';

### Adjust subject and body message
my $subject = 'A message with 2 parts ...';
my $message_body = "Here's the attachment file(s) you wanted";

### 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";

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

### Add the ZIP file
$msg->attach (
Type => 'application/zip',
Path => $my_file_zip,
Filename => $your_file_zip,
Disposition => 'attachment'
) or die "Error adding $file_zip: $!\n";
### Send the Message
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;


Posted by Sisyphus on June 26, 2006, 9:13 pm
Please log in for more thread options



> I have this simple Mime::Lite script quoted below.
> It works alright.
> But I would like to trace the result of the output.
> Something like
> set -x in ksh
> or anything else similar.
> Or some logging?
> What should I do and where should I put it?
>

At the beginning of your script:

open LOG, ">>/path/to/logfile" or die "Can't open log: $!";

Then, throughout your script, whenever you want to write something to the
logfile:

print LOG "Whatever you want to put in the logfile";

And at the end of the script:

close LOG or die "Can't close log: $!";

Cheers,
Rob



Similar ThreadsPosted
Perl Mime::Lite question. Help please? August 24, 2004, 8:45 am
MIME::Lite need sendmail Queue ID November 16, 2006, 9:34 am
Having trouble installing MIME::Lite module July 6, 2006, 4:25 pm
[MIME::Lite] not recognizing carriage-returns in body of message August 18, 2005, 5:06 pm
Template-Toolkit: Flushing Output or Incremental Output, how? September 13, 2007, 2:45 pm
SOAP::Lite : Problem of # sign added by SOAP::Lite in the sent SOAPActionstring November 5, 2004, 8:45 pm
output-monitoring module April 6, 2005, 11:38 am
getting output of telnet from perl April 6, 2006, 6:03 am
Sending output to Spreadsheet January 3, 2007, 12:22 am
pod2usage output options April 11, 2008, 8:48 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap