Page 1 of 1

problem with php mail

Posted: Fri Nov 21, 2003 10:44 am
by veenasv
Hi,
I am able to successfully send mails using the php mail function. My system has 2 hostnames one of those is the reverse proxy setup to hide the actual name of the computer. Whenever I send mails from php, at the receieivng end, I see in the from address, my actual system name being displayed. I would like to change the from address to be just webmaster in the display in stead of suffixing it with @localhost I know this can be done in smtp configuration. But don't know how. I also tried changing the from address in the Headers and included this as one of the parameters in Mail() but it didn't help.
I would appreciate any help in this regard.
I would like just to change the from address displayed at the receiving end.

Posted: Sun Nov 23, 2003 1:51 pm
by tsg
Sounds like you don't have the from address coded in. Might help if you post your code, but this works for me: Note that variables are set earlier in the script or form:

Code: Select all

<?php
if(mail($to,$subject,$message,"From: $email")) {
	print "message sent";
	} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}

?>

Posted: Mon Nov 24, 2003 5:07 pm
by veenasv
I tried with your example. Mail is sent successfully but again in the from address it's the hostname problem again. Somehow it appends the hostname
I had given it as
if(mail($to,$subject,$message,"From: $email"))
and $email = 'X6A webmaster';

still in the email it is displayed as X6a.webmaster@protein.nsls.bnl.gov

I just wanted it to display X6A webmaster

I feel it's something set in smtp configuration.

Posted: Mon Nov 24, 2003 5:13 pm
by tsg
Ok, I think I know what you are saying. You have to put the email address in there, but if you want the "From" just to say the name, then try this:

Code: Select all

<?php
$headers = "From: X6A webmaster <youremail@address.com>\r\n";

// then the send mail line:
mail($to, $subject,$message, $headers);

?>
Try that.

Posted: Tue Nov 25, 2003 11:08 am
by veenasv
Hi,
Thanks a lot . Your code is working partially in the sense, now From is displayed as what I gave in the $Headers. But the other SMTP address is being displayed as my original hostname and not the proxy name
X6A webmaster [SMTP:webmaster@x6aintranet.nsls.bnl.gov]
I want it to be [SMTP:webmaster@protein.nsls.bnl.gov]
Can you help me in this ?