johnpdmccall Posted December 10, 2006 Share Posted December 10, 2006 Hi all,How do I make [code]$replyemail="info@mycompany.co.uk";[/code]appear as "My Company Name"in the 'From' part of an e'mail.The line of code above is part of some PHP that e-mails me the results of a contact form and sends the user a copy. I'd like the user to see my company name.Many thanksJohn:) Quote Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/ Share on other sites More sharing options...
alpine Posted December 10, 2006 Share Posted December 10, 2006 You will have to define it in a header, "a should be minimum"-example:[code]<?php$headers = "From: $from_name <$from_email>\r\n"; // <-- This one sets the FROM name$headers .= "Reply-To: $from_name <$from_email>\r\n";$headers .= "Return-Path: $from_name <$from_email>\r\n";$headers .= "X-Mailer: PHP v".phpversion()."\r\n";mail($to_email, $subject, $message, $headers);// or mail with the fifth parameter set, not all setups allow it but it sets the correct return adressmail($to_email, $subject, $message, $headers "-f" . $from_email);// for instance, running php in safe mode disallows the fifth parameter, a simple if test determines the proper wayif(ini_get('safe_mode')){ mail($to_email, $subject, $message, $headers);}else{ mail($to_email, $subject, $message, $headers "-f" . $from_email);}?>[/code]Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138417 Share on other sites More sharing options...
johnpdmccall Posted December 10, 2006 Author Share Posted December 10, 2006 Thanks Alpine, I'll give that a tryCheersJohn Quote Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138427 Share on other sites More sharing options...
johnpdmccall Posted December 10, 2006 Author Share Posted December 10, 2006 Hi Alpine,I looked at your code and then tried simply replacing:$replymail= "info@mycompany.co.uk"with$replymail= "My Company Name <info@mycompany.co.uk>"and that works too but not sure if I'm leaving things insecure?ThanksJohn Quote Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138431 Share on other sites More sharing options...
alpine Posted December 10, 2006 Share Posted December 10, 2006 It shouldn't - but i is very difficult to say anything at all as long as you don't post your relevant code for this. Quote Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138433 Share on other sites More sharing options...
johnpdmccall Posted December 10, 2006 Author Share Posted December 10, 2006 Thanks Alpine,I didn't want to pester folks with a large bit of code but may do later once I've faffed about with it ;DCheersJohn Quote Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138443 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.