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: [email protected]'); ?> Do I need to use some headers or change something in the ini file? Quote Link to comment https://forums.phpfreaks.com/topic/136984-solved-mail-function-doesnt-do-from-correctly/ 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 <[email protected]>\r\n"); ?> EDIT: Removed a brace - don't know how it got there! Quote Link to comment https://forums.phpfreaks.com/topic/136984-solved-mail-function-doesnt-do-from-correctly/#findComment-715482 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 https://forums.phpfreaks.com/topic/136984-solved-mail-function-doesnt-do-from-correctly/#findComment-715487 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 https://forums.phpfreaks.com/topic/136984-solved-mail-function-doesnt-do-from-correctly/#findComment-715489 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 = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\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 https://forums.phpfreaks.com/topic/136984-solved-mail-function-doesnt-do-from-correctly/#findComment-715492 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 https://forums.phpfreaks.com/topic/136984-solved-mail-function-doesnt-do-from-correctly/#findComment-715507 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.