I am trying to set up an automatic mailer from a website, everything works apart from I am a little unhapy because the server appears in the from field, can I change this to some text of my choice, or a return email address?
Thanks very much in advance, Tom
mail() function sender details
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: mail() function sender details
Use the additional headers parameter in mail().tommy1987 wrote:I am trying to set up an automatic mailer from a website, everything works apart from I am a little unhapy because the server appears in the from field, can I change this to some text of my choice, or a return email address?
Thanks very much in advance, Tom
Code: Select all
$headers = "From: Your Name <your@address.com>\r\n";
$headers .= "Reply-To: Your Name <your@address.com>\r\n";Please can you give a peice of example code, I am not familiar with using headers.
e.g.
I cant seem to get it to work, excuse my ignorance, I am a newcomer to PHP.
e.g.
Code: Select all
$headers = "From: Blah Blah <blah@blah.com>\r\n";
$headers = "Reply-To: Tom lansdale <blah@blah.com>\r\n";
mail($to, $subject, $body);http://www.php.net/mailtommy1987 wrote:Please can you give a peice of example code, I am not familiar with using headers.
e.g.
I cant seem to get it to work, excuse my ignorance, I am a newcomer to PHP.Code: Select all
$headers = "From: Blah Blah <blah@blah.com>\r\n"; $headers = "Reply-To: Tom lansdale <blah@blah.com>\r\n"; mail($to, $subject, $body);
You'll notice when you put code in the PHP brackets, functions get underlined. You can click on the function and bring up an explanation of its use. Also, http://www.php.net has great resources on all functions, and an easy to use search in the upper right.
From what I linked:
Code: Select all
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>