Dear Monks,
I'm putting together a form to mail some data to one of users and am using Net::SMTP to mail them. However I keep coming across an error message whilst testing saying that I have an undefined value in
$smtp->mail( $from ); but I'm sure I have defined this further up the form. I would be grateful if somebody could point out what I have missed as this is the first time I've used this module and I'd like to leanr how to make it work properly.
Many thanks.
#! c:\perl\bin\perl.exe
use strict;
use warnings;
use cgi;
use Net::SMTP;
#constants
my $mailserver_url = "foo.bar.baz";
my $to = "foo\@bar";
my $from = "bar\@foo";
my $subject = "Mail time";
my $smtp = Net::SMTP->new('$mailserver_url');
#Sending the message
$smtp->mail( $from );
$smtp->to( $to );
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n"); # done with header
$smtp->datasend($name, $company, $country, $email);
$smtp->dataend();
$smtp->quit(); # all done. message sent.