il-fox
il-fox

Reputation: 75

Perl send email to web server without modules

I writing a program to do some monitoring on a server (email:[email protected]) then send an email to my laptop ([email protected]) which is connected to a web server (smtp.melita.com). After my email daniel....I tried adding the smtp port i.e. sendEmail("daniel.saliba\@melitaplc.com:25",.....) but I got /export/home/cassi/dead.letter...

P.S I cannot install any CPAN modules hence the code below.

The program executes without any errors but I do not receive the email.

sendEmail("daniel.saliba\@melitaplc.com", "cms1\@melitaplc.com", "ALERT", "This is a  test" );

sub sendEmail
 {
    my ($to, $from, $subject, $message) = @_;
    my $sendmail = '/usr/lib/sendmail';
    open(MAIL, "|$sendmail -oi -t");
            print MAIL "From: $from\n";
            print MAIL "To: $to\n";
            print MAIL "Subject: $subject\n\n";
            print MAIL "$message\n";
    close(MAIL);
 }

Upvotes: 2

Views: 762

Answers (1)

Flup
Flup

Reputation: 625

If you don't have access to install CPAN modules then you probably can't read your mail logs either... so you could try running

/usr/lib/sendmail -oi -t -v

on the command line, feeding it the same text your script sends it, and seeing what it does. The -v switch should give you lots of debugging information.

Upvotes: 2

Related Questions