Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Iam trying to send a file in a mail attachment in my Perl 5.6.1 on my Windows NT. I keep getting error message. Please advise how I can fix this????
use MIME::Lite; use Mail::Sendmail; use strict; use warnings; my $msg = MIME::Lite->new( From => 'smith@here.com', To => 'jones@here.com', Subject => "tester", Data => "The file is attached.\n" ); $msg->attach( Path => '\perl\bin\myerrs.txt', Type =>'AUTO' ); $msg->send;
My error message:
C:\Perl\bin>mailAttach.pl The name specified is not recognized as an internal or external command, operable program or batch file.
It doesnt seem to like the send method.

Replies are listed 'Best First'.
Re: Send Mail Attachment
by PodMaster (Abbot) on Oct 07, 2003 at 13:27 UTC
    Tutorials -> How to RTFM

    `perldoc MIME::Lite'

    ...
    
    Change how messages are sent
          ### Do something like this in your 'main':
          if ($I_DONT_HAVE_SENDMAIL) {
             MIME::Lite->send('smtp', "smtp.myisp.net", Timeout=>60);
          }
    
          ### Now this will do the right thing:
          $msg->send;         ### will now use Net::SMTP as shown above
    ...
    
    MIME::Lite->send()
        When used as a classmethod, this can be used to specify a different
        default mechanism for sending message. The initial default is:
    
            MIME::Lite->send("sendmail", "/usr/lib/sendmail -t -oi -oem");
    
        However, you should consider the similar but smarter and taint-safe
        variant:
    
            MIME::Lite->send("sendmail");
    
        Or, for non-Unix users:
    
            MIME::Lite->send("smtp");
    
    
    send either calls send_by_sendmail or send_by_smtp, you can RTFM further if you're interested.

    The F in RTFM is what you make of it, so make it good :)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Thank you!!!! It now works.
Re: Send Mail Attachment
by Abigail-II (Bishop) on Oct 07, 2003 at 13:09 UTC
    Are you sure you have sendmail installed on your machine? Because the error message suggest the program is trying to execute a program that can't be found.

    Abigail

      I have this sendmail that does work on my Windows NT using the sendmail. Please advise how I can get an attachment to work. Do I have to use the Mime module? Thanks
      use strict; use Mail::Sendmail; my %mailurl = ( To => 'jones@here.com', From => 'smith@here.com' ); $mailurl{smtp} = '111.222.2.22'; $mailurl{'Subject'} = "test"; $mailurl{'Message'} = "info"; sendmail(%mailurl) || die $Mail::Sendmail::error\n;