sendmail- will someone please tell me why this doesnt work...

They have: 447 posts

Joined: Oct 1999

ive been going over this again and again for hours, someone help!

#!/usr/local/bin/perl

$mailprog="usr/sbin/sendmail";

print "Content Type: text/html\n\n";
print "<h1>testing sendmail</h1>\n";

&send_mail;

sub send_mail {

open(MAIL,"|$mailprog -t");

print MAIL "To: robjohnson\@black-hole.com\n";
print MAIL "From: dillybar1\@black-hole.com\n";
print MAIL "Subject: sendmail test\n\n" }

print MAIL "Test email\n";
print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";

close (MAIL);
}

im sure the file paths are all correct, the script is at <a href="http://perl-plus.virtualave.net/cgi-bin/mailtest.pl">http://perl-plus.virtualave.net/cgi-bin/mailtest.pl</a>

They have: 447 posts

Joined: Oct 1999

correction, here is the script minus typos:

#!/usr/local/bin/perl

$mailprog="usr/sbin/sendmail";

print "Content Type: text/html\n\n";
print "<h1>testing sendmail</h1>\n";

&send_mail;

sub send_mail {

open(MAIL,"|$mailprog -t");

print MAIL "To: robjohnson\@black-hole.com\n";
print MAIL "From: dillybar1\@black-hole.com\n";
print MAIL "Subject: sendmail test\n\n";

print MAIL "Test email\n";

close (MAIL);
}

They have: 850 posts

Joined: Jul 1999

$mailprog="usr/sbin/sendmail";

shouldn't you have it as
$mailprog='usr/sbin/sendmail';
or
$mailprog="usr\/sbin\/sendmail";
?

------------------
Windmills always turn counter-clockwise. Except for the windmills in Ireland.

They have: 122 posts

Joined: Jun 2000

better yet, use the correct path to sendmail, i.e. /usr/sbin/sendmail instead of usr/sbin/sendmail. plus, look at the error logs. very helpful in determining what's wrong. if you try running that on a shell, does it work ok? if not, what errors does it give?

Rob Radez
OSInvestor.com

They have: 447 posts

Joined: Oct 1999

thanks for the suggestions, i will try them when i get home...

i believe i tried "usr\/sbin\/sendmail" but it didnt make a difference, i wasnt aware single quotes made a difference. i did forget that first '/' on the sendmail path, i dont think that was it though because i tried this...

open(MAIL,"|$mailprog -t");
close MAIL;

which did not give me an error, which means the path is correct, right?

also, script runs fine in a dos window, no errors, and virtualave says their sendmail prog is working fine.

when i get home ill change $mailprog to '/usr/sbin/sendmail' or "\/usr\/sbin\/sendmail" and see if that fixes anything.

Thanks again for the suggestions.

They have: 161 posts

Joined: Dec 1999

open(PROG, "|$mailprog -t"); will ONLY give you an error if you check the return value:

code:

open PROG, "|$mailprog -t" or
  die "can't run $mailprog -t: $!";
[/code]

The original code had two typos that I saw immediately.  A '}' where a ';' should have been, and the path to sendmail was missing the leading /.

And no, you don't need to backslash a / in a double-quoted string.  Backslash-fever is a very annoying Perl illness... I'd very much like to know where it started.

------------------
-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve 

They have: 447 posts

Joined: Oct 1999

$mailprog='/usr/local/bin/perl'; works just fine.

*slaps himself in the head*

funny how the toughest problems to find are the most obvious.

thanks for the help everyone

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.