Click to See Complete Forum and Search --> : PHP Email


kcis8rm
03-13-2007, 09:40 AM
Hi

I've set up a contact us form where a user can add their Email address, a subject and a message and used PHPs built in Email capbilities in the below function:

<?php
$to = "recipient@example.com";
$subject = $_REQUEST["subject"];
$body = $_REQUEST["message"];
mail($to, $subject, $body)
?>

Problem is when it arrives at the Email address the Email is from ananymous@ns.urlplace.net rather than my domain name. Can somebody tell me why this is, and better yet tell me how to fix it so that mail arrives with an address like enquiry@mydomain.net

Many thanks in advance

Ross

bokeh
03-13-2007, 09:58 AM
Before using this do a search for form validation.

kcis8rm
03-13-2007, 10:11 AM
Thanks, I do validate it before running this section of code, I just cut it out to keep the post to a miniumum! All the values being added to the mail section are what I'd expect. The mail arrives at the destination as expected, it is literally just the address that isn't coming through as expected?!

Could it be something to do with the way the server is set up, or am I missing some headers that would make a difference?

jogol
03-13-2007, 10:14 AM
$headers = "From: $name <$email>\n";

bokeh
03-13-2007, 10:21 AM
Try looking in the manual; as with most of the others, it deals with this function in great detail.mail($to, $subject, $body, 'From: webmaster@example.com')

kcis8rm
03-13-2007, 10:33 AM
Will do, thanks for the information :-)