Mail() .. Any way to change the "from" part?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

Mail() .. Any way to change the "from" part?

Post by Drachlen »

Okay im working on sending a person an email when someone registers, but the problem is it says from: noone@myhost.com Is there any way to change that so it matches my site? like register@myhost.com ?? I looked at a few tutorials on it, but it seemed like they were just including the "From" part inside the message... Is it possible?
jollyjumper
Forum Contributor
Posts: 107
Joined: Sat Jan 25, 2003 11:03 am

Post by jollyjumper »

Hi Drachlen,

Below is the way I use the mail function with a from email address:

Code: Select all

$ToMail = "thereceiver@somewhere.nl";
$FromMail = "register@myhost.com";
$Subject = "Example message";
$Content = "This is the content of the message\n\nGreetz Jolly";
$Header =     "From: $FromMail\r\n" ."Reply-To: $FromMail\r\n";
$Sendmail = mail("$ToMail","$Subject","$Content", "$Header");
Hope this helps you.

Greetz Jolly.
Post Reply