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 [email protected]. 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= "[email protected]"; //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 [email protected]</p><br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/ 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= "[email protected]"; //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 [email protected]</p> "; } ?> Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373268 Share on other sites More sharing options...
gwood_25 Posted October 19, 2007 Author Share Posted October 19, 2007 what did you change? Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373271 Share on other sites More sharing options...
darkfreaks Posted October 19, 2007 Share Posted October 19, 2007 the dots? Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373272 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? Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373277 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 Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373286 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. Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373289 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 Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373294 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 [email protected] ... 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. Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373300 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 Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373301 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? Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373303 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. Link to comment https://forums.phpfreaks.com/topic/73965-solved-change-from-address-in-email-sent-from-php-script/#findComment-373311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.