As I showed above, Net::SMTP->new() returns undef on failure. If you then try to call a method on this undef value, you effectively have undef->mail($FROM); — of course this method call will die! You need an explicit test for undef, to ensure that the mail(), to(), cc(), etc., methods are only ever called on defined objects. For example (untested):
my $smtp = Net::SMTP->new($INVALID, Debug => 3); if (defined $smtp) { $smtp->mail($FROM); $smtp->to($EMAIL); $smtp->cc($USEREMAIL); $smtp->data(); $smtp->datasend("From: $FROM \n"); $smtp->datasend("To: $EMAIL \n"); $smtp->datasend("Cc: $USEREMAIL\n"); $smtp->datasend("Subject: $SUBJECT \n"); $smtp->datasend("\n"); $smtp->datasend("$MAILTEXT \n"); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit; } else { print $@, "\n"; }
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: Net::SMTP halts script
by Athanasius
in thread Net::SMTP halts script
by nperrins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |