in reply to Re: using Mime::Lite
in thread using Mime::Lite

Thanks that got rid of the error, however, it still does not send the emails out...

Here is the file contents inside the subroutine.
my ($__to,$__cc,$__bcc,$__from,$__subject,$__html_message,$__text_mess +age,$__importance,$__xpriority,$__x_ms_priority) = @_; use MIME::Lite; my $_sendIp = $ENV{REMOTE_ADDR} || "127.0.0.1"; my $msg = MIME::Lite->new( 'From' => $__from, 'To' => $__to, 'Cc' => $__cc, 'Bcc' => $__bcc, 'subject' => $__subject, 'Type' => 'multipart/mixed', "X-Mailer" => "$_co_domain Mailer - Version 2.0", 'X-Organization' => "$_co_name", "X-Mail-Sent-For" => "$_co_name or www.$_co_domain/$_un; From +IP: $_sendIp", 'X-Priority' => $__xpriority, 'X-MSMail-Priority' => $__xpriority ); $msg->attach( 'Type' =>'TEXT', 'Data' =>"$__text_message", 'Disposition' => "inline" ); $msg->attach( 'Type' =>'HTML', 'Data' =>"$__html_message", 'Disposition' => "inline" ); my $_encEmPass = "43616c9765365f5f2640f311e1w1d5d6t2f3eacw052459ed4t4" +; $_encEmPass = decryptPass($_encEmPass); use Test::Trap qw/ :output(systemsafe) /; my $_sendError = ""; trap { $msg->send() or $_sendError = $@ }; $_ for $trap->die, $trap->stdout, $trap->stderr; if(!$_sendError and $_) { $_sendError = $_; } if($_sendError) { return (0,"$_sendError"); } else { return (1,""); }
Do you see why that would not send the email? I get not errors returned but no emails get sent out for some reason.

Thank you Perl Monks for your help and advice.

Replies are listed 'Best First'.
Re^3: using Mime::Lite
by jethro (Monsignor) on Aug 19, 2009 at 01:28 UTC

    What do you expect $_ for $trap->die, $trap->stdout, $trap->stderr; to do? It seems a noop to me. And $_ will be empty after that for-loop because the scope of the $_ in the for-loop ends with the loop. So testing $_ afterwards makes no sense, the if statement will never be executed

    Maybe you wanted to do print $_ for $trap->die, $trap->stdout, $trap->stderr; so that you at least can see when some message is printed on STDOUT or STDERR?

    Or you might have something like this in mind:

    my $allmessages.= $_ for $trap->die, $trap->stdout, $trap->stderr; if (!$_sendError and $allmessages) { $_sendError = $allmessages; }

    which would concatenate the values from all three methods and return that later

      Awesome that worked!

      When I changed that I then got an error, and I realized that with this program the email addresses should be seperated by a comma instead of the semi-colons... so I have it check them and replace them if they are semicolons... one last thing.

      I send it as a multipart email so that way if the email client the person is using is setup to read only in text they can see that and if html they see that, so it is based upon what they have their email client setup to do. My problem is that it is sending the text version as an attachment with the name: ATT0112.txt where the numbers are randomly generated. Why is it doing that? Is there a way to NOT do that? I have the Disposition set as inline, so I don't know why it is doing that.

      Thank you very much Xav

        You can give it a file name you like when you attach it.

        ...roboticus

        Without having tested it I see a few possibilities:

        1) It probably should be 'Content-disposition' instead of 'disposition', see MIME::Lite

        2) You may have a "defective" mail reader, see the following comment in MIME::Lite:

        Note: there are reports of brain-dead MUAs out there that do the wrong thing if you provide the content-disposition. If your attachments keep showing up inline or vice-versa, try scrubbing this attribute.

        3) Maybe your text is in utf8 format and you need to give that information with the 'Content-transfer-encoding' MIME header

        Generally you could compare a normal email with attachement to an email you received from your script and check what is different. All self-respecting mail readers allow you to view an email as unrendered source if you ask nicely ;-)