On Mar 2, 2004, at 8:51 PM, Baiss Eric Magnusson wrote:

And I have SendMail installed with a line

@EXPORT = qw(&sendmail);

What do you mean by "have SendMail installed with"...?


To begin with, the above exports sendmail(), not SendMail(). Also, if the above is in cwdmail.cgi, you've got it backwards. @EXPORT isn't something you put in cwdmail.cgi to import the sendmail() function. It's found *in* some other package, and it's a list of symbols that will be (as the name implies) exported from that package into whatever package uses it.

1) In <cwdmail.cgi> I have no objects so the whole file defaults to object <main>

Packages. All objects are packages - but not all packages are objects. In this case you're doing a simple non-OOP subroutine call, not an OOP method call, so they're packages.


because this is the line that fails:

$err = "Error sending mail: $Mail::SendMail::error" unless sendmail(%mail);

So now you're talking about Mail::SendMail. Is that what you meant above, when you referred to SendMail? Looking on CPAN, all I see is Mail::Sendmail - module and package names are case-sensitive, and they include all the components, not just the last word.


I'm not just nit-picking - looking on CPAN, I see Config::Manager::SendMail, Fatal::Sendmail, Mail::Mailer::sendmail, Mail::Sendmail, Mail::Transport::Sendmail, Siesta::Send::Sendmail, and Tindermail::Sendmail, among others. With only the last component of the module name, I can only guess at which one of these you're using, if any.

I'll assume you're using Mail::Sendmail. It's not an exact match to the code you've included, but it's the closest, and it exports a function called "sendmail()". Looking at the top of the perldoc page for Mail::Sendmail, I see this example:

use Mail::Sendmail;

%mail = ( To      => '[EMAIL PROTECTED]',
                From    => '[EMAIL PROTECTED]',
                Message => "This is a very short message"
        );

sendmail(%mail) or die $Mail::Sendmail::error;

print "OK. Log says:\n", $Mail::Sendmail::log;

So three suggestions:

1. Make sure you're doing "use Mail::Sendmail;" as illustrated in the example above. You're not exporting your own symbols into another package; you're importing another package's symbols into your own package, and for that you need "use", not "@EXPORT".

2. Check for misspelled and/or incomplete package names. It's "Mail::Sendmail", not "Mail::SendMail" or "SendMail".

3. You should also check out 'perldoc perlmod'. There's a *huge* amount of power to be found in CPAN, but you really do need to be able to use modules properly in order to take advantage of it.

sherm--



Reply via email to