ibjdt
Programmer
- Nov 25, 2002
- 63
i am stumped and don't know enough about what i am doing to know where to go from here.
i am programming a perl cgi script on an intranet site (windows server). part of the script's function is to email form information through our outlook system.
i am used to sendmail, but i have learned it won't work in my situation. plus i will eventually want to send attachments.
so i have been toying with Net::SMTP, but can't get that to work either. here's what i have:
i use valid emails for the 'to' and 'from' and change 'domain.com' to the common company email extension, but when i process i get two errors:
Can't open mail connection: domain.com
Can't call method "mail" on an undefined value at line 264
please help if you can.
thanks for your time.
i am programming a perl cgi script on an intranet site (windows server). part of the script's function is to email form information through our outlook system.
i am used to sendmail, but i have learned it won't work in my situation. plus i will eventually want to send attachments.
so i have been toying with Net::SMTP, but can't get that to work either. here's what i have:
Code:
$to = "me\@domain.com";
$from = "me\@domain.com";
$subject= "Test of PERL script to send email notice";
$body = "This is the body of the test message";
&send_mail($to, $from, $subject, $body);
sub send_mail {
my($to, $from, $subject, $body) = @_;
use Net::SMTP;
my $relay = "domain.com";
my $smtp = Net::SMTP->new($relay)
|| die "Can't open mail connection: $!";
$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");
$smtp->datasend("$body\n");
$smtp->dataend();
$smtp->quit();
}
i use valid emails for the 'to' and 'from' and change 'domain.com' to the common company email extension, but when i process i get two errors:
Can't open mail connection: domain.com
Can't call method "mail" on an undefined value at line 264
please help if you can.
thanks for your time.