PDA

View Full Version : need help with $message part of my code


web-gurl
07-25-2006, 02:21 AM
I have a file upload script that sends you an email if someone uploads to your server. I need to track who the uploaded files belong to and so I have a created a field in my form named your_email. I want to be able to see their email address in the message part of the email.

Here is part of the script:

sub send_mail {
my ($from_email, $from_name, $to_email, $to_name, $subject, $message ) = @_;

if(open(MAIL, "|$CONFIG{mailprogram} -t")) {
print MAIL "From: $from_email ($from_name)\n";
print MAIL "To: $to_email ($to_name)\n";
print MAIL "Subject: $subject\n";
print MAIL "$message\n\nSubmitter's IP Address : $ENV{REMOTE_ADDR}\n";
#### print MAIL Submitter's Email Address : $your_email"; ######
close MAIL;
return(1);
} else {
return;
}
}


As I am not a coder (obviously), I tried what I thought would be the code to use without success.

print MAIL Submitter's Email Address : $your_email";

I really would appreciate any help with this one line of code. From your help I can then add more fields if necessary.

Thank you

webgurl

nkrgupta
07-25-2006, 08:28 AM
Try this

sub send_mail {
my ($from_email, $from_name, $to_email, $to_name, $subject, $message ) = @_;

if(open(MAIL, "|$CONFIG{mailprogram} -t")) {
print MAIL "From: $from_email ($from_name)\n";
print MAIL "To: $to_email ($to_name)\n";
print MAIL "Subject: $subject\n";
print MAIL "$message\n\nSubmitter's IP Address : $ENV{REMOTE_ADDR}\nSubmitter's Email Address : $your_email\n";
close MAIL;
return(1);
} else {
return;
}
}

web-gurl
07-25-2006, 03:19 PM
Thank you for trying to help me, however, I had already tried that and still did not print email address so I am thinking something else needs customising in the script in a different section.

Two days on this and I am giving up!

KevinADC
07-25-2006, 06:28 PM
You can't add a form field named your_email and just use $your_email in the script and expect it to have the data sent from the form. Post the entire script, or if it's too long, post a link to a copy of the script. How you do what you want will depend on how the form data is being collected by your script.

FishMonger
07-25-2006, 07:41 PM
If you have a form field that the user is expected to fill in their email address, you'll need to make at least 2 checks. You need to verify that the field is not empty and that it holds a validly formatted email address.

However, a validly formatted email address doesn't mean that it's a valid address. You may also want to verify its validity by checking for the mx record. The format and mx record check can be done with the use of the Email::Valid module.
http://search.cpan.org/~rjbs/Email-Valid-0.175/lib/Email/Valid.pm

web-gurl
07-25-2006, 11:40 PM
As it is too long, please view here: http://webco.net.au/test.txt

Thank you again.