in reply to Mime::lite "no data" error again

Lets do some debugging: Throw out the first $msg->attach.... Do you see any error? Then throw out the second $msg->attach.... Do you see any error? If the error vanishes the thrown out statement is the problem

I looked at the source of MIME::Lite and the error message gets thrown when 'Data' is empty. So check either $text_mail or $pdf whether they really contain something exactly before attach is called. Use a print statement or the perl debugger

Replies are listed 'Best First'.
Re^2: Mime::lite "no data" error again
by Psychodead (Initiate) on Dec 09, 2009 at 11:26 UTC
    I just checked that. When commenting out the first attachment (where $text_mail is used), it works fine. I looked into that variable and as expected it contains my message text. Do I need quotations around the variable or something like that?

      Do you use 'use strict;'? You might have misspelled the name of the variable and strict mode will detect this.

      I don't think the text needs to be quoted, it is automatically quoted or translated to base64 by MIME::Lite.

      You could put a line with $text_mail= 'Testing'; just before the attach to check that the problem really is the contents of $text_mail

      If that works, change $text_mail to contain the first half of your message. If that works, the second half. If you find that one half doesn't work, half that again and see if you can pinpoint the problem.

        Hi! I have strict on, the variables name is correct. When I set it to $text_mail= 'Testing'; just before inserting it in the msg, it doesn´t fail. I receive this variable from another function. I tried writing the same test-string in it there and then passed it to my "sendmail"-function. It failed again. I have one main function calling the buildText(), then passing 2 params to the sendMail() like shown in the code below.
        buildText { #blabla return ($out, $text_mail ); } sendMail { my $p = { @_ }; my $body = $p->{body}; my $text_mail = $p->{text_mail}; #blabla } main_function { #blabla my ($body, $text_mail) = buildText(); return sendMail( body => $body, text_mail => $text_mail);