sphinx Posted May 8, 2012 Share Posted May 8, 2012 When recieving a php email and they put a 'from' email as: dfg@fgg.com, the email header shows as: Code: <?php if (isset($_REQUEST['email'])) { $email = $_REQUEST['email'] ; //who is message being sent to? $subject = $_REQUEST['subject'] ; //subject of email $from = $_REQUEST['from'] ; //who will email be from? $amount = $_REQUEST['amount'] ; //how many times do you want to send it? $message = $_REQUEST['message'] ; //what will content of message be? $from = $from; $length = $amount; for ($p = 0; $p < $length; $p++) { mail("$email", "$subject", $message."\n-----------\nThank you for using the service", "From:" . $from); } } $headers = "From:" . $from; header('Location: success.php'); How would I make it show like: Website name etc.. <dfg@fgg.com> Quote Link to comment https://forums.phpfreaks.com/topic/262255-from-header-not-displaying-properly/ Share on other sites More sharing options...
Adam Posted May 8, 2012 Share Posted May 8, 2012 Allowing the user to specify an "amount" of times to send the email is insane an idea. You're also opening yourself up to the possibility of being black listed. I can't think of any constructive reason to allow that anyway? To answer your original question, the "From" header can contain a name with an email in chevrons, just like your example: $headers = "From: Website name etc.. <" . $from . ">"; Obviously you could insert the user's name or whatever in there instead of a static string. Although you should know that the "on behalf of" text is added in because, basically, the email is claiming to be from somewhere it's not. You won't be able to get rid of it dynamically inserting emails into the from address. Edit The "Reply-To" header may be more what you're after? Quote Link to comment https://forums.phpfreaks.com/topic/262255-from-header-not-displaying-properly/#findComment-1343995 Share on other sites More sharing options...
sphinx Posted May 8, 2012 Author Share Posted May 8, 2012 Still showing 'on behalf of' i'm presuming it's server related as it didn't do it on my old host. Quote Link to comment https://forums.phpfreaks.com/topic/262255-from-header-not-displaying-properly/#findComment-1344001 Share on other sites More sharing options...
Adam Posted May 8, 2012 Share Posted May 8, 2012 Perhaps you had unknowingly white-listed the previous mail server or something? If you allow the user to provide the "From" header, then it's never going to match your mail server's domain (or your website's domain if they're different and you have a DKIM pass), and of course it wouldn't pass the SPF check. I'm no expert here though so someone else may say I'm wrong..? Quote Link to comment https://forums.phpfreaks.com/topic/262255-from-header-not-displaying-properly/#findComment-1344015 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.