Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Perl / Modules / June 2006



Tip: Looking for answers? Try searching our database.

How to log the output of Mime::Lite ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kenhensleys@yahoo.com - 26 Jun 2006 23:52 GMT
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;
Sisyphus - 27 Jun 2006 02:13 GMT
> I have this simple Mime::Lite script quoted below.
> It works alright.
[quoted text clipped - 4 lines]
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.