0

Hi Friends

I have written a perl script which sends an email on Windows using NetSMTP.

#!C:/cygwin/bin/perl
#print "Hello world";
use Net::SMTP;
use strict;
my $smtpserver = '10.154.118.140';
#my $smtpserver = '127.0.0.1';
my $smtpuser = 'myname';
my $fromemail = 'myname@mycompany.com';

    my $smtp = Net::SMTP-> new($smtpserver, Timeout => 10);
    $smtp-> mail($smtpuser);
    $smtp-> to('friend@mycompany.com');
    $smtp-> data();
    $smtp-> datasend("To: blblb\@blblbl.cz\n");
    $smtp-> datasend("From: psmejkal\@tesco.cz\n");
    $smtp-> datasend("\n");
    $smtp-> datasend("test\n");
    $smtp-> dataend();
    $smtp-> quit;

While executing the program Im getting the following error

Can't call method "mail" on an undefined value at ./mail.pl line 11.

Any clue?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by orwell84
0

Could it have anything to do with the fact that $smtpuser is not a valid email address? It's only the string 'myname'. The variable $fromemail is your email address.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.