CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Me Sendmail Script

 



Gzaector
Deleted

Jul 18, 2000, 12:08 AM

Post #1 of 4 (936 views)
Me Sendmail Script Can't Post

Hello,
I worte a simple PERL script for my website that reads input from the form when the user clicks submit and then emails me the form contents. I have a problem though when I type some info in the form and submit it the script runs great and it looks like it is doing what it is supposed to do but for some reason it does not send the email or I just dont recieve it I really need some help


havoc
Deleted

Jul 18, 2000, 3:17 AM

Post #2 of 4 (936 views)
Re: Me Sendmail Script [In reply to] Can't Post

if the script is right then there must be a problem with the mailing prgm..u havent specified whether u r using the MAIL or SENDMAIL prgm...find below sample code using the MAIL prgm....if u find it usefull....i can help u out further.

invoke this package in the perl prgm where you collect the script variables and pass them to the subroutine.
-----------------------------------------
#!/usr/bin/perl;
package mailer;

sub mailthis
{
my($sub) = $_[0];
my($body)= $_[1];
my($add) = $_[2];
my($cc)= $_[3];

$add = "yourname\@yoursite.com";
$cc = "ccname\@yoursite.com";

my($mail) = "mail -t -s \"$sub\" $cc $add";

open (MAIL,"|$mail") | | die("cannot fork mail");
print MAIL $body, "\n";
close MAIL;
}
1
;
-----------------------------------------


Gzaector
Deleted

Jul 18, 2000, 8:31 AM

Post #3 of 4 (936 views)
Re: Me Sendmail Script [In reply to] Can't Post

im using sendmail
here is my code

#!/usr/local/bin/perl
#
#2000 John Richards
#

if($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+//;
$value =~ s/%([a-fA-F0-9}{a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
open (EMAIL,"|/usr/lib/sendmail -t");
print EMAIL "To: $FORM{reciever}\n";
print EMAIL "From: $FORM{name}\n";
print EMAIL "Reply-To: $FORM{email}\n";
print EMAIL "Subject: Spudweb Studios\n\n";
print EMAIL "The visitor wrote:\n\n";
print EMAIL "$FORM{comments}\n\n";
if ($FORM{want_reply} eq "Yes")
{print EMAIL "*---Visitor wants a reply---*\n"; }
else
{print EMAIL "*---Visitor does not want a reply\n"; }
close (EMAIL);
&returnspudweb;
sub returnspudweb {
print "Location: http://www.spudweb.com\n\n";
}
}



errr
Deleted

Aug 15, 2000, 10:19 AM

Post #4 of 4 (936 views)
Re: Me Sendmail Script [In reply to] Can't Post

checking the return value of an open is usually a good idea.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives