Sending Email from Perl - PLEASE help

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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....
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: Sending Email from Perl - PLEASE help

    In article <1145987376.722945.130350@v46g2000cwv.googlegroups .com>,
    <"gpayne_onetel@hotmail.com"> wrote:
    > 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);}
    [rest snipped]
    > }
    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

  4. #3

    Default 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

  5. #4

    Default Re: Sending Email from Perl - PLEASE help

    Big thank you.

    Linux server cannot communicate with mail server.
    Penny dropped.

    gpayne_onetel@hotmail.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139