Perl Problem with emails, please help!
OK. I have got one for all you geniuses out there.I have a PERL script that I have on a server.
Here is the basic syntax
sub smtp_it {
# Function: Send email using SMTP protocol
$smtp = Net:

$smtp->mail('webmaster@mydomain.com');
# Recipient
$smtp->to($emailaddr);
# Stuff to send
my $text = join("","From: webmaster\@mydomain.com\n", "To: $emailaddr\n", "Subject: $emailsubject\n\n", $body);
# Send it
$smtp->data( $text );
$smtp->quit;
}
Here starts my problem. When I configure the email address to something that is hosted on the server then the mail goes out without a problem, even if it is not my domain but another hosted on the server.
When I configure the email address to an external address it doesn't arrive at the other end. As if the server is not allowing the mail into the queue.
Could someone give me any ideas why? Maybe some way to debug the script.
Second problem - another syntax
#!/usr/bin/perl
use Net:

$smtp = Net:

$smtp->mail('webmaster@mydomain.com');
$emailaddr="maish\@mydomain.com";
# Recipient
$smtp->to($emailaddr);
# Stuff to send
my $text = join("","From: webmaster\@mydomain.com\n","Subject: Test\n\n", "This is a test message");
# Send it
$smtp->data( $text );
$smtp->quit;
When I try to run the script through a ssh session on the server I get this error:
Can't call method "mail" on an undefined value at ./testmail.cgi line 6. (line 6 is in Bold)
Why???
Any help would be highly appreciated.
Thanks
Maish
www.eskayhosting.com