Why doesn't this work 2 ?

Ok, I wan't to send a simple e-mail sentence to my website using this script (see below). Somehow it doesn't work, so please help me out.

#!/usr/local/bin/perl
$mailserver="/var/qmail/bin/qmail-inject -t";
$test='Dutch_man@hotmail.com';
open(MAIL,"|$mailserver")||die "can't open sendmail\n";
print MAIL "To: $test";
print MAIL "Subject: $test";
print MAIL "Reply-to: $test\n\n";
print MAIL "$test\n\n";
close (MAIL);

oostwijkAsked:
Who is Participating?
 
yjh123Connect With a Mentor Commented:
I am sure you gave the 755 permission to the file.

Also, you tried  "perl filename" at UNIX prompt to see which line might have an error.

Why don't you try to sendmail instead?
Make sure to have "-t"

#!/usr/local/bin/perl
$mailserver="/usr/lib/sendmail";
$test="me\@yahoo.com";
open(MAIL,"|$mailserver -t")||die "can't open sendmail\n";
print MAIL "To: $test \n\n  ";
print MAIL "From: $test \n\n";
print MAIL "Subject: $test \n\n";
print MAIL "Reply-to: $test \n\n";
print MAIL "Real test\n\n";
close (MAIL);
print "Content-type: text/html\n\n";
print "done\n";

Also, create a web page that will call the cgi script:

<HTML><BODY>
<form METHOD="POST" ACTION="http://xxx.xxx.com/cgi-bin/XXX.cgi">
<input TYPE="submit" VALUE="SEND">
</FORM>

I ran it on my server and it works fine.
0
 
maneshrCommented:
you need to escape the @

$test='Dutch_man\@hotmail.com';
0
 
oostwijkAuthor Commented:
That doesn't work either, I keep getting a [500] internal server error. There must be something wrong with the script, but I can't figure out what it is.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
maneshrCommented:
are you running this program as a CGI??
if yes, add

print "Content-type: text/html\n\n";
print "done\n";

at the end of the code.

Also is qmail-inject the name of the program??or is -inject an option to qmail.

0
 
oostwijkAuthor Commented:
I added the
print "Content-type: text/html\n\n";
sentence already, that isn't giving the error. If qmail-inject the name of the program is or -inject an option to qmail is I don't know. I do know that I've got another very large script which uses the same e-mail function and works fine. I think i've mispelled something but I can't figure out what it is. Give it another try please.
0
 
oostwijkAuthor Commented:
well done, keep up the good work
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.