mapleleaf Posted December 15, 2008 Share Posted December 15, 2008 my mail function sends the from as my server's default from. How do I change this? <?php mail($_POST['email'], 'Registration Confirmation', $body, 'From: register@mysite.com'); ?> Do I need to use some headers or change something in the ini file? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted December 15, 2008 Share Posted December 15, 2008 Try this: <?php mail($_POST['email'], 'Registration Confirmation', $body, "From: My Site <register@mysite.com>\r\n"); ?> EDIT: Removed a brace - don't know how it got there! Quote Link to comment Share on other sites More sharing options...
mapleleaf Posted December 15, 2008 Author Share Posted December 15, 2008 That didn't do it but thanks for the idea. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted December 15, 2008 Share Posted December 15, 2008 I take it it sends the email OK? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted December 15, 2008 Share Posted December 15, 2008 This is an extract from the PHP manual on mail(): <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Full page: http://uk3.php.net/manual/en/function.mail.php That line of code you posted - is that the exact line you're using in your script? btw, notice the example I first changed I swapped your single quotes for double. Quote Link to comment Share on other sites More sharing options...
mapleleaf Posted December 15, 2008 Author Share Posted December 15, 2008 I normally do look at the manual first but not this time obviously. Works now. Thanks Yesideez 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.