Gossamer Forum
Home : General : Perl Programming :

trouble getting email sent with sendmail

Quote Reply
trouble getting email sent with sendmail
I have a web form presently with 5 inputs which need to pass (print to a web page) values after submit AND send an email (back to me).

The script I am using is:

#!/usr/bin/perl -wT
use strict;
use CGI ':standard';

my ($email_address, $reminder, $to, $from, $subject);

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

$to = param ('to');
$from = param ('from');
$subject = param ('subject');
$email_address = param ('email_address');
$reminder = param ('reminder');


print "$reminder\n";
print "$to\n";
print "$email_address\n";
print "$subject\n";
print "$from\n";


open (MAIL, "|usr/lib/sendmail -t") || Error ('open', 'mail program');

print MAIL "To: $to \nFrom: $from\n";

print MAIL "Subject: $subject\n";

print MAIL "$reminder\n";

print MAIL "$email_address\n";

close (MAIL);

Here's what I know:

1. The data does successful print upon submission. If you'd like to see go to http://joyofcode.com/remind_me.html (use id is bud and password is 050553 -- the site is under development but look around).

2. The location of sendmail is correct.

After that, I don't know much. I am real new in trying to teach myself PERL so if you can help -- and that would be greatly appreciated -- say it so I newbie would understand.

BTW -- I saw at another post in this Forum -- http://www.gossamer-threads.com/...confirmation_P53039/ someting that I thought was right on topic for me but I did not understand the solution.

Thanks so much!!

Bud
==============================
Bud Kraus
Your Friendly Instructor

Introduction To XHTML And CSS - The Online Workshop Teaching People How To Make Web Pages

http://www.joyofcode.com

973 235 1452
IM - accessbud
Quote Reply
Re: [trynet] trouble getting email sent with sendmail In reply to
Hi. Give the following a go;

Code:
#!/usr/bin/perl
use strict;
use CGI;

my $IN = new CGI;

my ($email_address, $reminder, $to, $from, $subject);

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

$to = param ('to');
$from = $IN->param('from');
$subject = $IN->param('subject');
$email_address = $IN->param('email_address');
$reminder = $IN->param('reminder');

print "$reminder\n";
print "$to\n";
print "$email_address\n";
print "$subject\n";
print "$from\n";

open (MAIL, "|/usr/lib/sendmail -t") || die &error ("Sendmail error : $!");
print MAIL "To: $to \nFrom: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "$reminder\n";
print MAIL "$email_address\n";
close (MAIL);

sub error {
my $error = $_[0];
$IN->header()
print "There was an error: <BR> $error";
exit;
}

The main bit, being the / missing on the path to sendmail Wink

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [trynet] trouble getting email sent with sendmail In reply to
Andy

Ooops -- so I put / in and still no mail. I did not change anything else.

I am passing these two hidden fields from the form:

<input type="hidden" name="to" value="webmaster@joyofcode.com" />
<input type="hidden" name="from" value="webmaster@joyofcode.com" />

Do I need to use an escape for @? Is this a problem? If so, how would that look?

Thgink not but I have to ask.

Thanks again!!

Bud
==============================
Bud Kraus
Your Friendly Instructor

Introduction To XHTML And CSS - The Online Workshop Teaching People How To Make Web Pages

http://www.joyofcode.com

973 235 1452
IM - accessbud

Last edited by:

trynet: Aug 21, 2004, 7:47 AM
Quote Reply
Re: [trynet] trouble getting email sent with sendmail In reply to
Did you try my version of the code?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [trynet] trouble getting email sent with sendmail In reply to
Oh, BTW.. just noticed;

print MAIL "Subject: $subject\n";

...it should be \n\n .. not just \n;

i.e;

print MAIL "Subject: $subject\n\n";

This is all I use for sending emails;

Code:
open(MAIL, "|$sendmail -t") || die &error($!);
print MAIL "To: $email \n";
print MAIL "From: $recipient \n";
print MAIL "Reply-to: $recipient \n";
print MAIL "Subject: $subject \n\n";
print MAIL "Thanks for contacting us. The information you submitted is below;\n\n";
print MAIL "$send\n";
print MAIL "\n";
print MAIL "We will try and get back to you ASAP\n";
print MAIL "\n";
close(MAIL);

Hope that helps.

BTW.. next time if you could reply to my post; then I will get an email notification :p

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] trouble getting email sent with sendmail In reply to
Andy

I added /n to the subject line -- no mail.

Here is the file as last run. It has your ideas from your first post but I commented out the last chunk because I think I am having end of line issues -- that is I don't know where the lines end.

I am using DzSoft Perl Editor on a w2k machine.

This will pass the date to the page -- but still no mail.

Thanks again. You are getting close to being added to my will.Smile

#!/usr/bin/perl -wT

use strict;
use CGI
':standard';

my $IN = new CGI;

my ($email_address, $reminder, $to, $from, $subject);

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



$to = param (
'to');
$from = $IN->param(
'from');
$subject = $IN->param(
'subject');
$email_address = $IN->param(
'email_address');
$reminder = $IN->param(
'reminder');



print
"$reminder\n";
print
"$to\n";
print
"$email_address\n";
print
"$subject\n";
print
"$from\n";



open (MAIL,
"|/usr/lib/sendmail -t") || die &error ("Sendmail error : $!");

print MAIL
"To: $to \nFrom: $from\n";

print MAIL
"Subject: $subject\n\n";

print MAIL
"$reminder\n";

print MAIL
"$email_address\n";

close (MAIL);

#sub error {
#my $error = $_[0];
#$IN->header()
#print "There was an error: <BR> $error\n";
#exit;
#}




==============================
Bud Kraus
Your Friendly Instructor

Introduction To XHTML And CSS - The Online Workshop Teaching People How To Make Web Pages

http://www.joyofcode.com

973 235 1452
IM - accessbud
Quote Reply
Re: [trynet] trouble getting email sent with sendmail In reply to
For one thing, $to is undefined. Change:

$to = param ('to');

to:

$to = $IN->param('to');


----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] trouble getting email sent with sendmail In reply to
Thanks Dan. I did that but nothing changed.
d
Form data still prints to a web page but I still don't get an email.

Any other ideas?

Bud
==============================
Bud Kraus
Your Friendly Instructor

Introduction To XHTML And CSS - The Online Workshop Teaching People How To Make Web Pages

http://www.joyofcode.com

973 235 1452
IM - accessbud

Last edited by:

trynet: Aug 21, 2004, 1:38 PM