Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent help needed re: Mail::Mailer 1

Status
Not open for further replies.

andycheese

Programmer
Jun 10, 2002
38
GB
Hi, I'm trying to use the Mail::Mailer module to send emails from a webpage (my sysadmin can't get to grips with sendmail configuration - not that I'm surprised, it looks horrific, but I digress). My script contains the following code (and includes the line use Mail::Mailer; at the top):

$mailer = Mail::Mailer->new("smtp", "$server" );
$mailer->open({ 'From' => 'My email system <email@foo.com>',
'To' => 'User <$email_addy>',
'Subject' => Subject goes here' });
print $mailer <<END_OF_MESSAGE;
Here is the email.

(Please do NOT reply to this message.)
END_OF_MESSAGE

$mailer->close();

Is this correct syntax? The error I get on the server log is:
Can't locate Mail/Mailer/smtp.pm in @INC (@INC contains: /usr/local/lib/perl5/5.
00502/sys3k /usr/local/lib/perl5/5.00502 /usr/local/lib/perl5/site_perl/5.005/sy
s3k /usr/local/lib/perl5/site_perl/5.005 .) at (eval 4) line 2.
httpd: [Tue Mar 11 11:29:54 2003] [error] [client 172.27.254.109] Premature end
of script headers: /opt/ncrhttp/cgi-bin/formtest.cgi

Now, this doesn't mean a lot to me, but I can deduce that perl is having touble finding the correct module. How is this so (if my assumption is correct?)? I downloaded it from CPAN and put it in a directory called Mail off the perl5/5.00502 directory. Please, some help would be greatly appreciated with this, as I'm a newbie to Perl and helpful, thorough advice has been a little hard to come by.

Thanks very much in advance!
 
Your interpretation of the error message is spot on but, to take a step back, sendmail is total overkill for a dedicated web-server. Look at the ssmtp package (packages.debian.org/stable/mail/ssmtp.html): it has a two-line configuration file so far as I can remember and allows you to send mail to another MTA for processing.

That aside, it sounds as if the installation of your Mail::Mailer package has got things a little askew. The correct layout of the various files (viewed from one of the directories listed as being in @INC) should be:
[tt]Mail
Mail/Field.pm
Mail/Util.pm
Mail/Mailer.pm
Mail/Address.pm
Mail/Filter.pm
Mail/Send.pm
Mail/Header.pm
Mail/Internet.pm
Mail/Cap.pm
Mail/Mailer
Mail/Mailer/rfc822.pm
Mail/Mailer/sendmail.pm
Mail/Mailer/smtp.pm
Mail/Mailer/test.pm
Mail/Mailer/mail.pm
Mail/Mailer/qmail.pm
Mail/Field
Mail/Field/AddrList.pm
Mail/Field/Date.pm
Mail/Audit.pm
Mail/Audit
Mail/Audit/KillDups.pm
Mail/Audit/List.pm
Mail/Audit/Razor.pm
Mail/Audit/MAPS.pm
Mail/Audit/PGP.pm[/tt]

Don't worry if you haven't got all of these but, if you do have them, they should be in the correct place. I got a warning bell when you said &quot;I downloaded it from CPAN and put it in a directory called Mail...&quot;: CPAN should complete the installation for you (including putting all files in the correct places) if (a) you have it set up correctly and (b) you ask it to.

Good luck, &quot;As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs.&quot;
--Maurice Wilk
 
Thanks very much fishiface. I have to confess to being a bit baffled by all these modules and their installation. As I said, finding an 'idiots guide' to setting up has been difficult! I thought it was as simple as downloading the modules from CPAN, as they are listed their and a number of perl books refer to them as individual, stand-alone modules. I guess not!

If it's not too impertinent, could you advise me on how to install modules?! Or, more even better, could you explain both (a) and (b) above please?
 
There is a bit of a chicken and egg situation involved: You need to correctly install the CPAN module and it then takes care of downloading and correctly installing all other modules. The first time that you run the CPAN module, it prompts you for various bits of information that it needs but, thereafter, it should be straightforward.

The module is documented at

Once you've got the module, you run
[tt]perl -M CPAN -e shell[/tt]
which gives you a command line interface prompt, with arguments for serching archives, downloading and installing.

Hope this helps,

yours &quot;As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs.&quot;
--Maurice Wilk
 
Thanks for your help, much appreciated. I warn you though, if I have any problems I may well post here again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top