Ask a Question related to PERL Modules, Design and Development.
-
gpayne_onetel@hotmail.com #1
Sending Email from Perl - PLEASE help
Hi,
I have written a simple script in PERL to monitor databases. The script
sends emails via an authenticated SMTP server.
Script works perfectly well in windows, but falls over in Linux with
error message
Can't call method "auth" on an undefined value at aimanage.pm line 22.
Offending Line $smtp->auth( $smtpUser,$smtpPasswd);
Works absolutely fine on Windows. Installed additional modules
Net-SMTP_auth and Authen::SASL
$smtpUser and SmtpPassword are definately defined.
Any suggestion would be greatly appreciated, as this has me completely
stumped.
Whole Script as follows:
sub send_email (@_)
{
my($subject,$message) = @_;
$smtp = Net::SMTP->new($smtpHost); # connect to an SMTP server
if ($authenicate ) { $smtp->auth( $smtpUser,$smtpPasswd);}
$smtp->mail( $smtpFrom ); # use the sender's address here
foreach $sendto (@smtpTo) { $smtp->to($sendto); }
# Start the mail
$smtp->data();
# Send the body.
$smtp->datasend("$message \n\n");
$smtp->datasend("More information in the Log file \n");
my($outline) = $dir . $logfile;
$smtp->datasend("$outline \n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
}
Many Thanks
Gareth.
gpayne_onetel@hotmail.com Guest
-
Sending email with flex
Hi, I am new to flex. And I am also new to web Services and remote Objects ;). I have a form. I collect the form and like to send it via email.... -
Sending email TO ColdFusion
Hi All, I'm looking for a way to record incoming email messages to a database. I want to be able to deal with all my site's mail through an... -
Sending an email from within ASP
I have a form which will be processed by being sent to an ASP page. I would like the ASP page to take the data from the Request.QueryString (which I... -
sending multiple email
Hi, I'm having problem sending e-mail to many people i.e in the To section i have abbbbb@abbb.com; In the Cc section i have accccc@accc.com... -
Sending an Email From Within Access
Is it possible to send an email from within an Access form? I would like to send one everytime a certain field is set to specific value. I... -
Jim Gibson #2
Re: Sending Email from Perl - PLEASE help
In article <1145987376.722945.130350@v46g2000cwv.googlegroups .com>,
<"gpayne_onetel@hotmail.com"> wrote:
[rest snipped]> Hi,
>
> I have written a simple script in PERL to monitor databases. The script
> sends emails via an authenticated SMTP server.
> Script works perfectly well in windows, but falls over in Linux with
> error message
>
>
> Can't call method "auth" on an undefined value at aimanage.pm line 22.
>
> Offending Line $smtp->auth( $smtpUser,$smtpPasswd);
>
> Works absolutely fine on Windows. Installed additional modules
> Net-SMTP_auth and Authen::SASL
> $smtpUser and SmtpPassword are definately defined.
>
> Any suggestion would be greatly appreciated, as this has me completely
> stumped.
>
> Whole Script as follows:
> sub send_email (@_)
> {
> my($subject,$message) = @_;
> $smtp = Net::SMTP->new($smtpHost); # connect to an SMTP server
> if ($authenicate ) { $smtp->auth( $smtpUser,$smtpPasswd);}
The Net::SMTP->new method is returning undef, which probably means it> }
is unable to connect to the SMTP host. Try adding ', Debug => 1' to the
argument list for new. Perhaps you have some connectivity problems
between the Linux system and the SMTP host that you do not have on the
Windows system.
Jim Gibson Guest
-
sm #3
Re: Sending Email from Perl - PLEASE help
<gpayne_onetel@hotmail.com> wrote in message
news:1145987376.722945.130350@v46g2000cwv.googlegr oups.com...==========================> Hi,
>
> I have written a simple script in PERL to monitor databases. The script
> sends emails via an authenticated SMTP server.
> Script works perfectly well in windows, but falls over in Linux with
> error message
>
>
> Can't call method "auth" on an undefined value at aimanage.pm line 22.
>
> Offending Line $smtp->auth( $smtpUser,$smtpPasswd);
>
> Works absolutely fine on Windows. Installed additional modules
> Net-SMTP_auth and Authen::SASL
> $smtpUser and SmtpPassword are definately defined.
>
> Any suggestion would be greatly appreciated, as this has me completely
> stumped.
>
> Whole Script as follows:
> sub send_email (@_)
> {
> my($subject,$message) = @_;
> $smtp = Net::SMTP->new($smtpHost); # connect to an SMTP server
> if ($authenicate ) { $smtp->auth( $smtpUser,$smtpPasswd);}
> $smtp->mail( $smtpFrom ); # use the sender's address here
> foreach $sendto (@smtpTo) { $smtp->to($sendto); }
> # Start the mail
> $smtp->data();
> # Send the body.
> $smtp->datasend("$message \n\n");
> $smtp->datasend("More information in the Log file \n");
> my($outline) = $dir . $logfile;
> $smtp->datasend("$outline \n");
> $smtp->dataend(); # Finish sending the mail
> $smtp->quit; # Close the SMTP connection
> }
>
> Many Thanks
>
> Gareth.
>
Here is my code that I have tested with couple ISPs.
#!/usr/bin/perl
# -*-Perl-*-
use Carp;
use Net::SMTP;
use strict;
my $msg = 'This is a simple Net::SMTP mailer test';
my $tolist = '<your email address>';
my $cclist = '';
my $logstr = 'this is the log string';
my $smtp = Net::SMTP->new('<your smtp server>',
Timeout => 30,
Debug => 1 ); # connect to SMTP server
$smtp->auth('DIGEST-MD5', # or 'CRAM-MD5' auth. method your smtp is using
'<your email address>',
'<your pass word>');
#$smtp->auth;
$smtp->mail('<your email address>'); # use the sender's adress here
$smtp->to('<recipient's email address>'); # recipient's address
$smtp->data(); # Start the mail
$smtp->datasend('testing the Net::SMTP mail\n');
$smtp->datasend('line 2\n');
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
exit;
-sm
sm Guest
-
gpayne_onetel@hotmail.com #4
Re: Sending Email from Perl - PLEASE help
Big thank you.
Linux server cannot communicate with mail server.
Penny dropped.
gpayne_onetel@hotmail.com Guest



Reply With Quote

