|
|
Question : getting error Can't call method "mail" on an undefined value
|
|
Hi,
when i run my sendmail.pl script from xyz server, it runs fine and sends the email. but when i run from different server "abc", it give me following error: Can't call method "mail" on an undefined value at line......
when i go to script that line contains: " $smtp->mail($senderEmail); "
my script:
sub sendMail(){ my ($message, $subject) = @_; my $smtp; print "Content-type: text/html\n\n";
$smtp = Net::SMTP->new($mailServer); # connect to an SMTP server $smtp->mail($senderEmail); # use the sender's address here $smtp->to($recipientEmail); # recipient's address $smtp->data(); # Start the mail
# Send the header. $smtp->datasend("To: $recipientEmail\n"); $smtp->datasend("From: $senderEmail\n"); $smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n"); # Send the body. $smtp->datasend("$message\n");
$smtp->dataend(); # Finish sending the mail $smtp->quit; # Close the SMTP connection -ab }
|
Answer : getting error Can't call method "mail" on an undefined value
|
|
Smtp Server is not in a Server Configuration. There is no specific SMTP Server for a particular Server. SMTP Server is configured inside the Application which communicates with it. If you have an application that works by communicating with SMTP Server on abc - check that application's configuration to find it out, nothing to do with the server itself.
|
|
|
|