Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email FROM Entry

Status
Not open for further replies.

Michael42

Programmer
Joined
Oct 8, 2001
Messages
1,454
Location
US
Generally I am finding the PHP mail() function easy to use except for setting who the email is comming from.

As I understand it mail()'s parameters are: mail(sendto, subject, message). Where is from????[surprise]

I need to set this dynamically so making a static entry in the php.ini file is not practical.

How can I do this?

Thanks,

Michael42
 
You can send additional headers as a fourth argument to mail(); The PHP documentation gives an example:
Code:
<?php
mail(&quot;nobody@example.com&quot;, &quot;the subject&quot;, $message,
     &quot;From: webmaster@{$_SERVER['SERVER_NAME']}\r\n&quot;
    .&quot;Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n&quot;
    .&quot;X-Mailer: PHP/&quot; . phpversion());
?>

I always recommend phpmailer.sourceforge.net because it takes all the thinking out of sending mail, may it be multipart MIME or not.
 
Keep in mind, too, that your MTA may affect how effective using the &quot;From:&quot; header will be.

For example, qmail is pretty picky about &quot;From:&quot; headers and may not use the headers you provide. Qmail takes sender information from environment variables.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
a little less confusing look..


mail (&quot;toperson@domain.com&quot;, &quot;Hey&quot;, &quot;did you get this email?&quot;, &quot;From: me@domain.com&quot;)


you can also use Reply-to: where from is.. and i think CC: and BSS: or something.

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
Thanks - your suggestions worked great!

Michael42
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top