Go Premium for a chance to win a PS4. Enter to Win


Sending Email - Problem

Posted on 2003-11-14
Medium Priority
Last Modified: 2008-02-01
Hi All,
I am getting a problem while sending the Email.Here is the code for that.
use MIME::Entity;

sub emailRpt
      my ($fileToEmail, $locationOfFile) = @_;
      my $toEmailList = getConfigString("AVD_ADDENDUM_DATE_REPORT", "toEmailList");
      my $fromEmailAddress = getConfigString("AVD_ADDENDUM_DATE_REPORT", "fromEmailAddress");
      my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( );
        $mon = sprintf("%02d", $mon);
        $mday = sprintf("%02d", $mday);
        my $subject = "$reportName  ${mon}\/${mday}\/${year}";
            my $body = "Report Attached";

      print LOG "Email is been sent to $toEmailList with subject $subject and file attached is -$fileToEmail \n";      


Now i am getting this error while trying to send this email.

This error was when i did not do anything on the system.
egypt IT_test_nbo_27_fst_prov> perl v
Can't locate MIME/Entity in @INC (@INC contains: /usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 223. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 223. BEGIN failed--compilation aborted at v line 14.
After copying Entity.pm
egypt IT_test_nbo_27_fst_prov> perl v
Can't locate MIME/ToolUtils.pm in @INC (@INC contains: /usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 223. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 223. BEGIN failed--compilation aborted at v line 14.
After copying ToolsUtils.pm
egypt IT_test_nbo_27_fst_prov> perl v
Can't locate MIME/Head.pm in @INC (@INC contains: /usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 224. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 224. BEGIN failed--compilation aborted at v line 14.
After copying everying under the MIME directory from scarlet Unix System  to egypt Unix System egypt . It is working fine on scarlet Unix System  but on egypt. scarlet and egypat are name of the Unix box. So do not get confused from that.
IT_test_nbo_27_fst_prov> perl v Can't locate IO/Wrap.pm in @INC (@INC contains: /usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 .) at /usr/local/lib/perl5/site_perl/5.005/MIME/Head.pm line 111. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/MIME/Head.pm line 111. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/MIME/Entity.pm line 224. BEGIN failed--compilation aborted at v line 14. egypt IT_test_nbo_27_fst_prov>
Now it seems that egypat Unix box is not having that Entity.pm module which creating problem.I do not have privilages to change that and we are using PERL 5.005003
Now i am having a question here whether we can modify this code in some way so that it can work.

Thanks in advance.

Question by:akku_batra
  • 2
  • 2
LVL 20

Accepted Solution

jmcg earned 100 total points
ID: 9753063
The short answer is that you will get the greatest satisfaction if the Perl environments on the various servers can be brought up to the same level -- same version of Perl, same suite of modules installed.

If that's not possible, you can get fairly close using the approach that it seems you are already using: installing the missing modules into whatever filesystem space you are allowed to use on the server. Perl's

use lib qw(/path/to/library);

statement can be added at the top of your scripts to enable use of these additional modules.

In the Perl FAQ, there's a question "how do I keep my own module/library directory" that addresses this general topic, but it does not quite tell you what to do when you are copying files over to a server where you do not have full login privileges. Because you can only copy files, you may find you can't install some modules this way because they require compilation of some components on the target machine. That can effectively prevent you from using such a module.

LVL 48

Assisted Solution

Tintin earned 100 total points
ID: 9767577
As jmcq says, you don't install modules by just blindly copying files.  You use the standard way of installing, ie:

perl Makefile.PL
make test
make install

Why are you using  MIME::Entity to send mail?  Most people use MIME::Lite as it is very easy to use (and install)

Expert Comment

ID: 9767579
The perl CPAN module will help you install those modules correcly (it will also take care of the dependency issues that you are encountering).  Problem is that you will likely need root to run it successfully. The command to run is:

perl -MCPAN -e 'install MIME'
LVL 48

Expert Comment

ID: 9767607
Hence the reason MIME::Lite is better to use as it consists of a single file.
LVL 20

Expert Comment

ID: 10093394
Nothing has happened on this question in more than 7 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between jmcg and Tintin.


EE Cleanup Volunteer

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question