in reply to Re^3: Sending email in perl
in thread Sending email in perl

THis is the code that gives me the error. Even if I change it to use Net::SMTP_auth I will get the same error. Note I have removed my UID and PASS for security and the @ in my email to prevent harvisting
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use Net::SMTP; $smtp = Net::SMTP -> new('mail.ffinfo.com'); $smtp -> auth('UID', 'PASS'); $smtp -> mail('ffxils ffinfo.com'); $smtp -> to('ffxils ffinfo.com'); $smtp -> data(); $smtp -> datasend("To: \"Crystal Reverine Admins\" <ffxils\@ffinfo.com +>\r\n"); $smtp -> datasend("From: \"Crystal Reverine Registration Script\" <ffx +ils\ ffinfo.com>\r\n"); $smtp -> datasend("X-Mailer: Crystal Rebberine Registration Script Net +::SMTP\r\n"); $smtp -> datasend("Subject: New Member Reqestrations\r\n"); $smtp -> datasend("\r\n"); $smtp -> datasend('A new member has registered at the LS website and i +s waiting for approval. Please click on the below link to get a list +of all waiting members'); $smtp -> dataend(); $smtp -> quit();

Replies are listed 'Best First'.
Re^5: Sending email in perl
by GrandFather (Saint) on Sep 16, 2005 at 01:04 UTC

    $smtp = Net::SMTP -> new('mail.ffinfo.com') is failing so $smtp is not created. Have you got the address of the smtp server right?

    As a general comment: you should use warnings; use strict;.


    Perl is Huffman encoded by design.
      The code work 100% before my host started requireing authentication. and I do have
      #!user/bin/perl -w use strict; use Net:SMTP;
      I just forgot to highlight that part.

        Are you sure the SMTP server name didn't change at the same time? I get the error message "Can't call method "auth" on an undefined value at noname.pl line 6." when I run the following code:

        use warnings; use strict; use Net::SMTP; my $smtp = Net::SMTP -> new('wibble'); $smtp -> auth('URI', 'PSWD'); $smtp -> quit();

        which strongly implies to me that the new failed and $smtp is undef.

        The use strict; ... remark is like a standard disclaimer around here :)


        Perl is Huffman encoded by design.
Re^5: Sending email in perl
by BaldPenguin (Friar) on Sep 16, 2005 at 14:46 UTC
    Have you tried to wrap your code in an eval and evaluate the error message that comes back?
    eval { # code here }; if ($@) { confess "$@"; }

    Don
    WHITEPAGES.COM | INC
    Everything I've learned in life can be summed up in a small perl script!