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

I am using use Mail::Sendmail for sending mail on my NT scripts. Now I am writing a script on Solaris 7 server and cant find the module on this Unix server where I have Perl 5.8. Please advise how I can load this module into my home directory and how I would call it?
#!/usr/local/bin/perl use warnings; use strict; use lib '/usr/home/myname/Mail/Mailer/'; use Mail::Sendmail; my %mailurl = ( To => 'tomail@here.com', From => 'frommail@here.com' ); $mailurl{smtp} = '111.111.1.11'; print "unix test.\n"; $mailurl{'Subject'} = "UNIX test"; $mailurl{'Message'} = "test only."; sendmail(%mailurl) || die "\n smtp problem! $Mail::Sendmail::error\n";

Replies are listed 'Best First'.
Re: Loading sendmail module
by jey (Pilgrim) on Jan 29, 2004 at 16:31 UTC

    There is a solution in the "Perl Cookbook":

    # syntax for sh, bash, ksh, or zsh $ export PERL5LIB=$HOME/perllib # syntax for csh or tcsh % setenv PERL5LIB ~/perllib

    Or a solution in "Learning Perl Objects, References & Modules", which is to start your script by:

    BEGIN {shift @INC, "/home/perlib";}

    where perlib is always the directory that contains Mail/Sendmail.pm

    --
    jey
      I just found an old one under Perl 5.005 directory:
      /usr/local/lib/perl5/site_perl/5.005/Mail/Mailer
      I tried calling it but gives me back an error message saying:
      Can't locate Mail/Sendmail.pm in @INC (@INC contains:.....etc..
      Here is how I did it:
      use lib '/usr/local/lib/perl5/site_perl/5.005/Mail'; use Mail::Sendmail;
      Please advise

        Try using:

        use lib '/usr/local/lib/perl5/site_perl/5.005';

        Or if it doesn't work, I would definitely advice the

        BEGIN...
        --
        jey
Re: Loading sendmail module
by Fletch (Bishop) on Jan 29, 2004 at 16:33 UTC
    perldoc perlmodinstall
Re: Loading sendmail module
by blue_cowdawg (Monsignor) on Jan 29, 2004 at 16:37 UTC

    I am a bit confused by what you mean by:

        Please advise how I can load this module into my home directory and how I would call it?
    If you mean "How do I build the module into my home directory?" check out A Guide to Installing Modules under the section entitled "I don't have permission to install a module on the system!" and follow the instructions.

    My other advise would be to establish a good working relationship with your Solaris SysAdmin and sweet-talk him or her into installing the module for you system-wide. Sometimes beer, a carbonated beverage of their choice, coffee, sex, drugs or bribery will help! It will save you trouble in the long run.


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.