in reply to Re^4: How can I send email with attachments if MIME::Lite isn't available?
in thread How can I send email with attachments if MIME::Lite isn't available?

My spelling is not the issue. ..... MIMI::Lite is not available from my host.

MIMI::Lite will not be available from any host, as it does not exist. MIME::Lite does exist, though we aren't sure with regard to your host since you have yet to convince anyone that you're actually trying to invoke MIME::Lite instead of MIMI::Lite. Is there something wrong with your browser that you're unable to see the difference between I and E? Because Perl cares.

You also cannot just copy Lite.pm to some folder and expect Perl to know it's there. It's just a little more complicated than that.

Post a snippit of code here that is no longer than 20 lines, that shows how you're sending email, and we can try to help you debug it. Post real code that replicates the error. And while you're at it, tell us what you mean by "it doesn't work." Be specific. Show the actual error message. Help comes to those who give us something to work with.


Dave

  • Comment on Re^5: How can I send email with attachments if MIME::Lite isn't available?

Replies are listed 'Best First'.
Re^6: How can I send email with attachments if MIME::Lite isn't available?
by bigjoe11a (Novice) on Jun 22, 2005 at 21:20 UTC

    Thats just it Dave, there are no errors, The script works find, It just would send any thing. Look, heres a part of my code

    require "Lite.pm"; $msg = MIME::Lite->new( To =>$sendtoemail, From =>$useremail, Cc =>$useremail, Subject =>'You got a webcard!', Type =>'multipart/related' ); push (@attachments, [ Type => 'image/gif', Id => 'mygreeting', Path => "$real_imagepath/$greeting", ]); if ($no_thumb eq "ON") { $mtext .= <<EOX; <center> Here's <i>my</i> image:<br> <img src="cid:mythumb"> </center> EOX push (@attachments, [ Type => 'image/gif', Id => 'mythumb', Path => "$real_imagepath/$thumb", ]); } if ($no_image eq "ON") { $mtext .= <<EOX; <center> Here's <i>my</i> image of you:<br> <img src="cid:myimage2"> </center> EOX push (@attachments, [ Type => 'image/jpg', Id => 'myimage2', Path => "$real_imagepath/$image", # filename => "$image", # Disposition => 'attachment' ]); } if ($no_photo eq "ON") { $mtext .= <<EOX; <center> Here's <i>my</i> image of you:<br> <img src="cid:photo"> </center> EOX push (@attachments, [ Type => 'image/jpg', Id => 'photo', Path => "$real_imagepath/$photo", # filename => "$photo", # Disposition => 'attachment' ]); } $msg->attach(Type => 'text/html', Data => "<body>\n" . $mtext . "</body>\n"); foreach $attachment (@attachments) { $msg->attach(@$attachment); } $str = $msg->as_string; $msg->print(\*SENDMAIL); $msg->send ('sendmail', '/usr/lib/sendmail -t');

    <code> tags added by davido per consideration.

      You don't need to have both a $msg->print(\*SENDMAIL); line and a $msg->send( 'sendmail', '/usr/lib/sendmail -t' ); line. That's at best redundant.

      Try checking the return value of $msg->send(...). If it returns false, you've got failure. If it returns true MIME::Lite at least thinks it succeeded.

      This is a CGI script, so your error messages (if any) should appear in the webserver's error log, unless you've used CGI::Carp with the fatalsToBrowser() option. That means it will be failing silently unless you dig into the webserver log. Whatever's in that log could be quite telling.

      It's also possible that MIME::Lite has dependancies not satisfied by just copying Lite.pm into your local directory. As a matter of fact, if you're working with a CGI script, the script may not be executed with the working path you think it has, and that could result in Lite.pm not being found by your simple require. Again, this sort of thing would turn up in the error logfile for the webserver.

      By the way, if someone were to hit your site with WWW::Mechanized, they could use it as an anonymous spam relay. The spam would look like an eCard with whatever text they choose to fill into the form. With a little forking they could hit you pretty hard. Beware of any CGI mailing script that allows the user the ability to send anonymously, and to set the recipient either via form data or manipulation of hidden fields. It's a bit of a security risk. It would be less useful as a spam relay if you explicitly limited the amount of text that could be sent in the message body down to a sentence or two.


      Dave

        Sorry, Dave, I wanted to tell you that for some reason it working. I have have no idea why it's working now. A perl programer and I work on it for 3 days and still couldn't get it to send mail out. any way it's working, so thank you for your time. Joe
      Assuming '.' is in @INC, create a folder MIME, then move Lite.pm into that folder. That will allow perl to find MIMI::Lite's methods. The path of the module used should be the same as the package statement within the module.