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.
problem with php mail
Moderator: General Moderators
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.";
}
?>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.
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.
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:
Try that.
Code: Select all
<?php
$headers = "From: X6A webmaster <youremail@address.com>\r\n";
// then the send mail line:
mail($to, $subject,$message, $headers);
?>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 ?
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 ?