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

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?

Replies are listed 'Best First'.
Re^3: Mime::lite "no data" error again
by jethro (Monsignor) on Dec 09, 2009 at 12:08 UTC

    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);

        There has to be something wrong with your variable $text_mail. Is the attach method you showed in your original post called in the sub sendMail? Or somewhere outside? It could be a scoping issue.

        Please insert the following in your program just before the attach and provide the result:

        use Data::Dumper; print Dumper(\$text_mail); $msg->attach( ...

        This will show exactly what is in $text_mail at the moment you call attach (it will even show hidden control characters should there be any)