Not exactly sure what you mean, but here's a couple of examples:
# example #1
eval q{
my $msg = Mail::Sender->new( {
from => 'you@example.com',
to => 'me@example.net'
} );
} or die("mail error: $Mail::Sender::Error");
# example #2
eval q{
my ($from, $to) = ('you@example.com', 'me@example.net');
my $msg = Mail::Sender->new( {
from => $from, to => $to
} );
} or die("mail error: $Mail::Sender::Error");
# example #3
eval q{
my %vars = (
from => 'you@example.com', to => 'me@example.net'
);
my $msg = Mail::Sender->new( \%vars );
} or die("mail error: $Mail::Sender::Error");
| [reply] [d/l] |
It would be extremely useful if you gave us a snippet of what you were trying - it'd help when trying to show where you're heading in the wrong direction.
some_func(
To => 'joe@mama.com',
Subject => $subject,
);
| [reply] [d/l] |
Unless it's a prototyped function, a parameter list is a parameter LIST. If it's prototyped to take a hash, you should pass it a hash (something beginning with %). It wouldn't hurt to do that, anyway.
But I see from the docs that Mail::Sender wants a hash ref. Put your list in braces or put a backslash in front of your %.
If you include some actual, minimal code that demonstrates the problem you're having, we could run it ourselves and it would be easier to debug.
Caution: Contents may have been coded under pressure.
| [reply] [d/l] [select] |
Sorry about that guys, thought it might be a generic enough question to not NEED a code sample.
my $from_name = $mail_from;
my $from_address = $display_name;
my $to_address = $_;
my $subject = 'Daily Report';
my $mime_type = 'TEXT';
my $message = "Your PDF report is attached.";
# Create the initial text of the message
my $mime_msg = MIME::Lite->new(
From => $from_address,
To => $to_address,
Subject => $subject,
Type => $mime_type,
Data => $message
)
or die "Error creating MIME body: $!\n";
my $filename = 'daily.pdf';
my $recommended_filename = 'daily.pdf';
# Attach the file
$mime_msg->attach(
Type => 'application/pdf',
Path => $filename,
Filename => $recommended_filename
)
or die "Error attaching test file: $!\n";
As you can tell from the code, most, if not ALL the of important info comes from variables, most of which come from a config file, or are retrieved from a database. | [reply] [d/l] |
I installed MIME::Lite, took your code above, put in the missing "use MIME::Lite;" at the top, and ran it with perl 5.8.5. No compilation errors, no die's were triggered. Is this the exact piece of code that, by itself, is triggering the problem you're having?
Thanks,
| [reply] |