Jump to content

Resetting user password by sending email


Azsen

Recommended Posts

Hi,

 

I want to create a forgotten password page, where the user enters in their email address, the script queries the database for that email address, creates a unique ID, stores that unique ID in the database, then emails the unique ID and the User ID off to the user in an HTML link e.g. http://somesite.com/reset-password.php?userId=2&uniqueId=132832189312978312. The reset page would then match the unique ID to the one in the database and let them enter in a new password into the form.

 

Ok so I can do most of that so far except from the emailing to the user. I'm running an Ubuntu Server 10 at the moment as my test server which is on my local network. Do I need to set up a mail server on that for php mailing to work, or can I use some external SMTP for sending? I've had a play round with the PHP mail() function but it won't send anything at the moment. I'll also need some code for when the site is running in the hosted live environment as it will likely use their mail servers.

 

What's the best way to go about doing this?

Many thanks!

Link to comment
Share on other sites

I've been playing with the PEAR mail sending functionality on this example:

http://www.blog.highub.com/javascript/javascript-core/make-ubuntu-php-localhost-mail-function-work/comment-page-1/#comment-3059

 

It actually sends the email and I can get it in my gmail but I get about 50 lines of errors saying:

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Mail/mimePart.php on line 307

Strict Standards: Non-static method Mail_mimePart::encodeHeader() should not be called statically, assuming $this from incompatible context in /usr/share/php/Mail/mime.php on line 1316

Strict Standards: Non-static method Mail_mimePart::_explodeQuotedString() should not be called statically, assuming $this from incompatible context in /usr/share/php/Mail/mimePart.php on line 827

Strict Standards: Non-static method Mail::factory() should not be called statically in /opt/lampp/htdocs/sportsite/sendmail.php on line 28

 

What's up with that?

 

Also do many web hosts have PEAR on them? I'm a bit dubious about relying on it if most web hosts don't actually run it.

Link to comment
Share on other sites

Ended up using Zend for emailing in the end.

 

Forget about using PEAR for email until they fix the strict error messages. Seems to be broken at the moment. You can always turn the error messages off with ini_set('display_errors', '0'); but that's probably not the best solution.

 

The Zend mail functionality is very good and not too hard to figure out.

http://zendframework.com/manual/en/zend.mail.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.