gwood_25 Posted October 19, 2007 Share Posted October 19, 2007 Hello, I have a strange problem that I'm not sure how to solve. I have a web form that collects name, email and message from users of my website. This info is posted to a php script which then emails the info to our email address. The problem is, the from address never gets changed from webmaster@ourdomain.com. I haven't specified this address in the script at all and am adding extra headers to try and change the from address to the email addy specified by the user....here is my script. Any help is greatly appreciated. <?php header("Cache-Control: no-cache, must-revalidate"); $mail_to= "info@mysite.com"; //address I want the website emails going to $Name =$_GET['Name']; $mail_from=$_GET['Email']; $mail_sub="Message from Wheatcity Cowtown Website"; $mail_mesg=$Name."<".$mail_from."> wrote: \n\n".$_GET['Message']; $headers = $mail_from."\r\n"."Reply-To:".$mail_from."\r\n"; if(mail($mail_to,$mail_sub,$mail_mesg,$headers)) { echo "<br><br><p align=center>E-mail has been sent successfully</p>"; } else { echo "<br><br><p align=center>Failed to send the E-mail, please try again or contat us info@wheatcitycowtown.com</p><br>"; } ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 19, 2007 Share Posted October 19, 2007 <?php header("Cache-Control: no-cache, must-revalidate"); $mail_to= "info@mysite.com"; //address I want the website emails going to $Name =$_GET['Name']; $mail_from=$_GET['Email']; $mail_sub="Message from Wheatcity Cowtown Website"; $mail_mesg=$Name"<"$mail_from"> wrote: \n\n"$_GET['Message']; $headers = $mail_from"\r\n""Reply-To:"$mail_from"\r\n"; if(mail($mail_to,$mail_sub,$mail_mesg,$headers)) { echo " <p align=center>E-mail has been sent successfully</p>"; } else { echo " <p align=center>Failed to send the E-mail, please try again or contat us info@wheatcitycowtown.com</p> "; } ?> Quote Link to comment Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 what did you change? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 19, 2007 Share Posted October 19, 2007 the dots? Quote Link to comment Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 removing the dots breaks the script. The dots are required for concatenation aren't they? Please bear with me I am very new to php and I am not sure what the issue is. I am able to send mail successfully with my original script, it just won't change the from address or teh reply to address. This site is hosted with yahoo and runs on a linux server does this make a difference? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 19, 2007 Share Posted October 19, 2007 not really double quotes will still parse the variables so there is really no need for the dots Quote Link to comment Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 I tried running your code and it didn't work. When I put the dots back in... it worked. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 19, 2007 Share Posted October 19, 2007 <?php $mail_mesg="$Name<$mail_from> wrote: \n\n ".$_GET['Message'].""; $headers = "$mail_from \r\n Reply-To:$mail_from \r\n";?> ^ correct code you still need the dots for get message otherwise it wont work but it should parse the other variables Quote Link to comment Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 ok, but the original question still remains.... why won't the "from" address in my mail client appear as the email addy submitted via the web form. It always displays as info@domain.com ... I can't change it. The reason I want to change it is so that I can easily reply to a customer message without copying and pasting. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 19, 2007 Share Posted October 19, 2007 edit : nevermind you could try changing the reply header into a link? dunno if it would work Quote Link to comment Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 Thank you so much for your help. I'm not sure if maybe this is a yahoo issue and they don't allow you to change this setting? Quote Link to comment Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 the code i have and that you modified for me should work under normal circumstances, however, yahoo doesn't allow you to send email via script that has a return address who's domain is outside of your hosted domain. If the return address domain is outside of the hosted domain, a default return address is used instead. This is a yahoo specific setting and is inteded for anti-spam measures. Thank you again for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.