in reply to Re^5: 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?

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.

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

Replies are listed 'Best First'.
Re^7: How can I send email with attachments if MIME::Lite isn't available?
by davido (Cardinal) on Jun 23, 2005 at 01:03 UTC

    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
Re^7: How can I send email with attachments if MIME::Lite isn't available?
by Anonymous Monk on Jun 23, 2005 at 01:13 UTC
    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.