Mail function help

I opened up a site on tripod (for testing purposes) and i’m trying to use the mail function in the following way:
mail($to, $subject, $body, “From : Example <>”);
yet when i get the mail in the “from” section i see:
From: Example <>

does anyone know how do i change it to <> ?

You can try using the fifth parameter of the mail() function:


Note there is no space between the f and the e-mail address!

Interesting. I checked the same code on two different webhosts. One shows the address i have given in php mailto headers, while the other shows the address of the host. Can you try your code on some other host?

i’m quite sure it’s a host problem, they just override it, thanks anyway

i’m guessing lycos override this because no matter how i write it it i always get From: Example <>

You need to set the headers in order to change out the default PHP configuration.

$to = '';
$subject = 'subject test';
$message = 'Hey!';
$headers = 'From:';

mail($to, $subject, $message, $headers);

tried that also, doesn’t work

I think Scallio was right but I think you have to be redundant and include the header info and then the -f. Here is an example with notes:

$name = ""; // Recipients Name
$email = ""; // Recipients Email Address
$sitename = ""; // Your Site Name
$admin = ""; // Site Email Address
$recipient = "$name <$email>"; // Put them Together
$headers = "From: $sitename <$admin>\
$body = ""; // Body of the Email
$subject = ""; // Subject of the Email
mail($recipient, $subject, $body, $headers, "-f" . $admin);

If that does not work, change the last line to:

mail($recipient, $subject, $body, $headers);