in reply to Passing variables to function's hash.

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.

Replies are listed 'Best First'.
Re^2: Passing variables to function's hash.
by FrankRizzo (Acolyte) on Jan 18, 2005 at 22:52 UTC
    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.

      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,

        *sigh* Have you ever had it happen? You ask a question, and in the process of reading the responses the answer comes to you? Well, it happened to me. I pasted that code, and while reading the comments figured out that I was doing stupid things in my attempts to set up the fields. (And, in the process, pasted the WRONG code. I have 4 or 5 modules here, all with different e-mail libs, all failing for some different reason, and I picked the wrong one. But, thanks anyway guys! As it turned out, you helped more than you know! Frank