Trium918 Posted April 10, 2007 Share Posted April 10, 2007 Is it possible to send an email from localhost using the script below? function notify_password($username, $password) // notify the user that their password has been changed { if (!($conn = db_connect())) return false; $result = mysql_query("select email from user where username='$username'"); if (!$result) return false; // not changed else if (mysql_num_rows($result)==0) return false; // username not in db else { $email = mysql_result($result, 0, "email"); $from = "From: support@phpbookmark \r\n"; $mesg = "Your PHPBookmark password has been changed to $password \r\n" ."Please change it next time you log in. \r\n"; if (mail($email, "PHPBookmark login information", $mesg, $from)) return true; else return false; } } Quote Link to comment Share on other sites More sharing options...
gluck Posted April 10, 2007 Share Posted April 10, 2007 As long as your php.ini file has the servername and other config params set. you should try it and if it doesn't work paste the error. Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 As long as your php.ini file has the servername and other config params set. you should try it and if it doesn't work paste the error. I think I find one but could someone give me the others to look for. sendmail_from = me@example.com Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 No result. I am getting echo"Your password could not be mailed to you. Try pressing refresh." from Not sure if this is correct!! sendmail_from = me@example.com changed to sendmail_from = localhost <? require_once("bookmark_fns.php"); do_html_header("Resetting password"); if ($password=reset_password($username)) { if (notify_password($username, $password)) echo "Your new password has been sent to your email address."; else echo "Your password could not be mailed to you." ." Try pressing refresh."; } else echo "Your password could not be reset - please try again later."; do_html_url("login.php", "Login"); do_html_footer(); ?> Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 Does anyone know how to send an email from localhost? Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 Does anyone know how to send an email from localhost? This the code inside of php.ini [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 Does anyone have an idea, Yes or No? Quote Link to comment Share on other sites More sharing options...
per1os Posted April 10, 2007 Share Posted April 10, 2007 You need a mail server. You also need your PORT 25 open, without that it probably won't work. google mail servers Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 You need a mail server. You also need your PORT 25 open, without that it probably won't work. google mail servers I'm not sure frost110, but Window suppose to have one built into it right. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 10, 2007 Share Posted April 10, 2007 Not that I know of. I think you either have to find freeware or download it. I know linux comes bundled with sendmail, but not windows. Remember windows was built for "dumb" users to just click. Why would they want to educate and make life easier for their users =) Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 Not that I know of. I think you either have to find freeware or download it. I know linux comes bundled with sendmail, but not windows. Remember windows was built for "dumb" users to just click. Why would they want to educate and make life easier for their users =) Im trying it your way right quick. Be right back Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 You need a mail server. You also need your PORT 25 open, without that it probably won't work. google mail servers I couldn't get it working so I'll have to set it up on another server. Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted April 10, 2007 Share Posted April 10, 2007 Why do you need to send from localhost? Just send it from an email address on your server. me@mysite.com. Quote Link to comment Share on other sites More sharing options...
Trium918 Posted April 10, 2007 Author Share Posted April 10, 2007 Why do you need to send from localhost? Just send it from an email address on your server. me@mysite.com. Just practice to get a better understanding of it. My server is Apache on a Windows platform. 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.