johnpdmccall Posted December 10, 2006 Share Posted December 10, 2006 Hi all,How do I make [code]$replyemail="[email protected]";[/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:) 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 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 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= "[email protected]"with$replymail= "My Company Name <[email protected]>"and that works too but not sure if I'm leaving things insecure?ThanksJohn 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. 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 Link to comment https://forums.phpfreaks.com/topic/30105-solved-formmail/#findComment-138443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.