Hi everyone,
I have a little problem with a form to email which is getting spammed, and the solution, I've been told is to strip carriage returns (\r) and linefeed characters (\n) from form fields in my cgi scripts - with the following code:
$field =~ s/\r/ /g;
$field =~ s/\n/ /g;
for each field used in an email.
So, in my code, sample below, what do i change and where!! I tried;
print MAIL "To: $email =~s/\r /g"; but that didnt work...
maybe print MAIL "From: $domain\n\r"; ???
I don't know!!
what should it be?? If someone could amend the code below to include $field =~ s/\r/ /g; & $field =~ s/\n/ /g; for each field used in an email I would be INCREDIBLY grateful!!!
Thanks in advance
amx
CODE below:
sub mailMe
{
my($form,$data) = shift;
my($sendmail,$name,$domain,$email) =
('/usr/lib/sendmail','Mann Scuba Divers',' myemail@hotmail.com');
open MAIL, "|$sendmail $email" or die "Can't open sendmail: message = '$!'";
print MAIL "To: $email\n";
print MAIL "From: $domain\n";
print MAIL "Subject: $form->{subject}\n\n";
print MAIL "Dear $name,\n\n";
for(@{$form->{Seq}}) { print MAIL "$_\t\t : ",$form->{$_},"\n" and $data = 1 }
print MAIL "The input form was empty\n" unless $data;
print MAIL "\n\nYours truly,\nThe Mail Room";
close MAIL or die "Can't close sendmail: message = '$!'"
}
I have a little problem with a form to email which is getting spammed, and the solution, I've been told is to strip carriage returns (\r) and linefeed characters (\n) from form fields in my cgi scripts - with the following code:
$field =~ s/\r/ /g;
$field =~ s/\n/ /g;
for each field used in an email.
So, in my code, sample below, what do i change and where!! I tried;
print MAIL "To: $email =~s/\r /g"; but that didnt work...
maybe print MAIL "From: $domain\n\r"; ???
I don't know!!
what should it be?? If someone could amend the code below to include $field =~ s/\r/ /g; & $field =~ s/\n/ /g; for each field used in an email I would be INCREDIBLY grateful!!!
Thanks in advance
amx
CODE below:
sub mailMe
{
my($form,$data) = shift;
my($sendmail,$name,$domain,$email) =
('/usr/lib/sendmail','Mann Scuba Divers',' myemail@hotmail.com');
open MAIL, "|$sendmail $email" or die "Can't open sendmail: message = '$!'";
print MAIL "To: $email\n";
print MAIL "From: $domain\n";
print MAIL "Subject: $form->{subject}\n\n";
print MAIL "Dear $name,\n\n";
for(@{$form->{Seq}}) { print MAIL "$_\t\t : ",$form->{$_},"\n" and $data = 1 }
print MAIL "The input form was empty\n" unless $data;
print MAIL "\n\nYours truly,\nThe Mail Room";
close MAIL or die "Can't close sendmail: message = '$!'"
}