LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2004, 04:25 AM   #1
robertwo
LQ Newbie
 
Registered: Jun 2004
Posts: 4

Rep: Reputation: 0
Angry CGI Script runs to send mail, but mail is never sent


I have a a linux box that is being used as a web server.

The versions are Red Hat Linux release 7.2 (Enigma) Kernel 2.4.7-10 on an i686.

The problem I am having is a follows:

We use forms on our website to collect customers infor and enquires. When these forrms are submitted the call a CGI/PERL script that basically emails the details through using SENDMAIL and then send the user on to a THANK YOU page.

The forms submit, and the thank you page is displayed, but no email is sent!

I have tried manually sending mail using the commands in the script and mail is sent, well externally, but not to internal recipients.

Is there any way to see exactly what is happening such as a log or a way of modifing the script to give some sort of visual feedback to confirm the mail has been sent.

The script is as follows:

#!/usr/bin/perl






#load email addresses

open PTR,"../Data/emails.txt" or warn("Content-Type: text/html\n\nCould not open email address file");
@emails=<PTR>;
close PTR;

foreach(@emails)
{
chomp;
s/\r//g;
}

use CGI;
# create new CGI object
$q=CGI->new();

# now get the details
$firstname=$q->param('FirstName');
$lastname=$q->param('LastName');
$initial=$q->param('Initial');
$title=$q->param('Title');
$job=$q->param('JobTitle');
$phone=$q->param('Telephone');
$email=$q->param('eMail');
$company=$q->param('CompanyName');
$addr=$q->param('CompanyAddress');
$town=$q->param('Town');
$county=$q->param('CountyState');
$country=$q->param('country');
$postcode=$q->param('PostCodeZIP');
$website=$q->param('WEBURL');
$destid=$q->param('Destid');
$comments=$q->param('Comments');

open MAIL, "| sendmail -oi -t ";

print MAIL "From: <website\@simgroup.com>\r\n";
print MAIL "To: <$emails[$destid]>\r\n";
print MAIL "Reply-to: <iain.furneaux\@simgroup.com>\r\n";
print MAIL "Subject: Form submission from SIM web site\r\n";
print MAIL "\r\n";
print MAIL "

$title $firstname $initial $lastname has visited the SIM web site and requested more details about us or
a product/service that we offer. $title $lastname works for $company, the contact details for $title $lastname
are as follows: (Destid=$destid)

$title $firstname $initial $lastname
$job
$company
$addr
$town
$county
$country
$postcode

email: $email
Tel: $phone

if you want to find out a little more about this company then the web site address entered was $website.

$title $lastname also submited the following comments:

$comments\r\n
";

close MAIL;


$root=$ENV{'HTTP_REFERER'};
$root=~s/\/[A-Za-z0-9\.\-\_]+$//;

if($destid==5)
{
print "Location: $rootRegistrationThankU.html\n\n";
}
else
{
print "Location: $root/ContactThankU.htm\n\n";
}
 
Old 06-09-2004, 06:14 AM   #2
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
I believe you have to have some sort of mail server running on your machine. Like qmail or squirrel mail. I have never dealt with running a mail server (though I considered it once) so I cannot help you with them. Look into that though, that may be all you need to do.

If you get it working, please post how, I may just give it a whirl myself. May I use that script you posted if I do?

Good luck,
 
Old 06-10-2004, 09:57 AM   #3
robertwo
LQ Newbie
 
Registered: Jun 2004
Posts: 4

Original Poster
Rep: Reputation: 0
There is a mail server running on the machine, SENDMAIL which I think is part of, or an add on of Linux.

Mail does try and get sent but it is bounced straight back.

Anybody else have any ideas?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shel script mail send ("/" in mail address) problem anaid Linux - Networking 3 08-23-2005 07:41 AM
How do I send mail from inside a script? bruno buys Linux - Software 3 10-06-2004 07:57 PM
bash script to send mail Cruger Programming 1 03-06-2004 08:25 AM
howto send a mail with attachment via perl script ? cccc Programming 24 03-05-2004 07:49 PM
I'm looking for a simply perl script to send mail, when ping down cccc Programming 2 01-12-2004 04:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration