Forgotten password code

I want to enable users the facility of having their password mailed to them based on user name. Fairly standard stuff.
Here's how I see it.
Link from 'Forgotten password' opens jsp/html page, user enters user name in text field then clicks on submit.
The submit button then runs a java bean which interrogates a mysql database, extracts the password and mail address based on user name then mails the user.
If success, an alert box pops up saying 'password mailed' otherwise alert box pops up with failure.
I can set everything up as far as extracting the relevant information, the bit I'm stuck on is how to send a mail from within a java bean
Any help appreciated
Thanks

well, there are a lot of examples you can find on the net.
i can't find right now the code i use for this stuff. but i found a base for the method i have, you have to check it and fix it, this is an early "check_how_it_works" version, the method signature has too many variables you don't actually need and you can change it as you want.
import javax.mail.*;
import javax.mail.internet.*;
public void sendEmail(int to_number,String [] emailto, String emailfrom, String smtphost, String emailmultipart, String msgSubject, String msgText)
     boolean debug = false; // change to get more information
     String msgText2 = "multipart message";
     boolean sendmultipart = Boolean.valueOf(emailmultipart).booleanValue();
     // set the host
     Properties props = new Properties();
     props.put("mail.smtp.host", smtphost);
     // create some properties and get the default Session
     Session session = Session.getDefaultInstance(props, null);
     session.setDebug(debug);
     try
     // create a message
     Message msg = new MimeMessage(session);
     // set the from
     InternetAddress from = new InternetAddress(emailfrom);
     msg.setFrom(from);
     InternetAddress[] address = new InternetAddress[to_number];
     for(int i=0;i<to_number;i++)
          address=new InternetAddress(emailto[i]);
     msg.setRecipients(Message.RecipientType.TO, address);
     msg.setSubject(msgSubject);
     if(!sendmultipart)
     // send a plain text message
     msg.setContent(msgText, "text/plain");
     else
     // send a multipart message// create and fill the first message part
     MimeBodyPart mbp1 = new MimeBodyPart();
     mbp1.setContent(msgText, "text/html");
     // create and fill the second message part
     //MimeBodyPart mbp2 = new MimeBodyPart();
     //mbp2.setContent(msgText2, "text/html");
     // create the Multipart and its parts to it
     Multipart mp = new MimeMultipart();
     mp.addBodyPart(mbp1);
     //mp.addBodyPart(mbp2);
     // add the Multipart to the message
     msg.setContent(mp);
     Transport.send(msg);
     catch(MessagingException mex)
     mex.printStackTrace();

Similar Messages

  • Help with unlocking a disabled ipad 2! When I put it in recovery mode Itunes wants the password/ code that I've forgotten...

    The computer says that it's extracting software etc then it gets to a certain point when it says, please enter ipads password / code...
    This I've forgotten..
    What can I do?

    Hi and thanks for your reply,
    it still doesn't work.
    I ve  followed the steps promted by iTunes three times and every time it gets to a stage when "it" says now enter the password or code to your ipad.
    I have forgotten the password/code, and then it's back to square one again...?
    Kind regards David

  • I have set up as security password-code for home screen.  So when I turn it on, I forgotten the correct code and I'm locked out for 60 minutes ;(  How do I retrieve or reset so I can use phone

    I have set up as security password-code for home screen.  So when I turn it on, I forgotten the correct code and I'm locked out for 60 minutes ;(  How do I retrieve or reset so I can use phone again. Please help!

    You need to connect to iTunes and restore the iPhone to remove the passcode...then from a recent backup restore the content.

  • HT1212 I have forgotten my password/code on my iPhone!

    I have just downloaded the new software and I deside to chage my password. Soon after doing an task I come back and forgottern my passcode.  I need help!! How can you find your password/code WITHOUT syncing to your computer?

    thankyou anyway

  • Reset forgotten password glitch

    Working through the Powers' latest book. Everything seemed to be working fine in local testing environment recently. When I uploaded the files tonight to the remote server and did a test of the forgotten password feature, I'm getting a message at the top of the Request Received screen (p. 293) that says "Connection refused" and not seeing the reset email come in. The request_reset.php code is below:
    isValid($_POST['email'])) {        $errors = TRUE;      }      if (!$errors) {        $sql = $dbRead->quoteInto('SELECT user_id, first_name, last_name, email FROM users WHERE email = ?', $_POST['email']);        $result = $dbRead->fetchRow($sql);        if (!$result) {           $errors = TRUE;        } else {         // update database and send mail           $token = md5(uniqid(mt_rand(), TRUE));           $data = array('token' => $token);           $where = $dbWrite->quoteInto('email = ?', $_POST['email']);           $dbWrite->update('users', $data, "user_id = {$result['user_id']}");             }        $mail = new Zend_Mail('UTF-8');        $mail->addTo($result['email'], "{$result['first_name']} {$result['last_name']}");        $mail->setSubject('Instructions for resetting your password');        $mail->setFrom('[email protected]', 'Wild Felid Association');        $link = "http://www.conmolbry.com/WFRMA/reset.php?id={$result['user_id']}&token=$token";        $message = "Use the following link to reset your password. This link can be used once only. $link";        $mail->setBodyText($message, 'UTF-8');        $mail->send();      }   } catch (Exception $e) {      echo $e->getMessage();   } }Peter

    David thank you the first approach did not work but the second one did. At least I got the email with the token link. However, when I click on the link it takes me to an error page that says:
    Not Found
    The requested URL /WFRMA/reset.php was not found on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    The reset.php file is sitting right there in the root directory. This is the reset_password.php code if it means anything in resolving this further hiccup:
    <?php
    session_start();
    $errors = array();
    $success = FALSE;
    $_SESSION['nomatch'] = TRUE;
    require_once('library.php');
    try {
      if (isset($_GET['id']) && isset($_GET['token'])) {
         $id = $dbRead->quote($_GET['id']);
         $token = $dbRead->quote($_GET['token']);
         $sql = "SELECT user_id FROM users WHERE user_id = $id AND token = $token";
         $result = $dbRead->fetchRow($sql);
         if ($result) {
          $_SESSION['user_id'] = $_GET['id'];
           $_SESSION['token'] = $_GET['token'];
           $_SESSION['nomatch'] = FALSE;
      if (isset($_POST['reset'])) {
         // password reset code goes here
         $val = new Zend_Validate();
         $val->addValidator(new Zend_Validate_StringLength(8,15));
         $val->addValidator(new Zend_Validate_Alnum());
         if (!$val->isValid($_POST['password'])) {
           $errors['password'] = 'Use 8-15 letters or numbers only';
         $val = new Zend_Validate_Identical($_POST['password']);
         if (!$val->isValid($_POST['conf_password'])) {
           $errors['conf_password'] = "Passwords don't match";
         if (!$errors) {
           // update the password
           $data = array('password' => sha1($_POST['password']),
                         'token'    => NULL);
           $where['user_id = ?'] = $_SESSION['user_id'];
           $where['token = ?'] = $_SESSION['token'];
           $success = $dbWrite->update('users', $data, $where);
           unset($_SESSION['user_id']);
           unset($_SESSION['token']);
           unset($_SESSION['nomatch']);
    } catch (Exception $e) {
      echo $e->getMessage();
    Thanks.

  • Forgotten password B2C CRM 5

    Hi All
    Can anyone tell me what needs to be setup for the forgotten password function in B2C webshop works. I can setup a new account and log on, but if I try to use the forgotten password it gives a message saying. Password can not be found.?
    Any help would be app.
    Thanks
    Paul

    If it has been disabled after entering the wrong passcode - http://support.apple.com/kb/HT1212.
    Unfortunately, you must restore it in iTunes on your computer.   There is no way to retrieve a forgotten pass lock code.
    You will need to restore your device from the same computer that you most recently synced to, and restore the device. See - http://support.apple.com/kb/HT1414.

  • TS3716 Forgotten password on original ipad, how do I reset?

    My husband has an original ipad from years ago but he has forgotten the password/code to get in.  It's not synced to any of our computers or iTunes so we need to know how to reset it to new again.  Any advice how to do this?

    You will need to Restore your Device...
    iPad User Guide iOS 5
    http://manuals.info.apple.com/en_US/ipad_user_guide.pdf

  • Forgotten password to get into my ipod touch

    Does anyone know how to restore a 5th generation Ipod touch?  My  son forgot his password and now can not get into his Ipod.
    Thanks, Sue

    If You Are Locked Out, Have Forgotten Your Passcode, or Just Need to Restore Your Device
    1. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. iOS- Understanding passcodes
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. How to Recover Forgotten iPhone Restrictions Passcode | The iPhone and iPad
         If you have forgotten your Restrictions code, then follow the instructions
         below but DO NOT restore any previous backup. If you do then you will
         simply be restoring the old Restrictions code you have forgotten. This
         same warning applies if you need to restore a clean system.
    A Complete Guide to Restore or Recover Your iDevice (if You Forget Your Passcode)
    If you need to restore your device or ff you cannot remember the passcode, then you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and re-sync the data from the device (or restore from a backup). If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present. Refer to Updating and restoring iPhone, iPad and iPod touch software.
    Try restoring the iOS device if backing up and erasing all content and settings doesn't resolve the issue. Using iTunes to restore iOS devices is part of standard isolation troubleshooting. Restoring your device will delete all data and content, including songs, videos, contacts, photos, and calendar information, and will restore all settings to their factory condition.
    Before restoring your iOS device, Apple recommends that you either sync with iTunes to transfer any purchases you have made, or back up new data (data acquired after your last sync). If you have movie rentals on the device, see iTunes Store movie rental usage rights in the United States before restoring.
    Follow these steps to restore your device:
         1. Verify that you are using the latest version of iTunes before attempting to update.
         2. Connect your device to your computer.
         3. Select your iPhone, iPad, or iPod touch when it appears in iTunes under Devices.
         4. Select the Summary tab.
         5. Select the Restore option.
         6. When prompted to back up your settings before restoring, select the
              Back Up option. If you have just backed up the device, it is not necessary
              to create another.
         7. Select the Restore option when iTunes prompts you (as long as you've backed up,
             you should not have to worry about restoring your iOS device).
         8. When the restore process has completed, the device restarts and displays the Apple
             logo while starting up:
               After a restore, the iOS device displays the "Connect to iTunes" screen. For updating
              to iOS 5 or later, follow the steps in the iOS Setup Assistant. For earlier versions of
              iOS, keep your device connected until the "Connect to iTunes" screen goes away or
              you see "iPhone is activated."
         9. The final step is to restore your device from a previous backup. If you do not have a
              backup to restore or have forgotten your restrictions passcode, then restore as New.
    If you are restoring to fix a forgotten Restrictions Code or as a New device, then skip Step 9 and restore as New.

  • I am stuck in an App with Guided Access and have forgotten pass code? Help!

    I have forgotten pass code for Guided Access and can not get of the App? I don't know what to do next? I have tried resetting by holding Home button and on/off for 10 seconds. What now?

    Hi Suzanne
    If you continue to be unable to guess the passcode by brute force attempts, you can connect the device to a computer that has synced the device and unlock things with a sync.
    If you have never synced with iTunes then you can try this:
    1.Hold the Lock Button
    2.Slide the Slide To Power Off slider [If touch is disabled/you're unable to slide it, do a hard reset — hold the lock and home button until the Apple Logo appears]
    3.When your iDevices powers up, immediately exit the app that automatically opens.
    4.Go to Settings > General > Accessibility > Guided Access
    5.Click Set Passcode
    6.Enter new password
    7.Reboot again.
    8.Wait for the app to automatically open and Triple tap the home button
    9.Enter the new password

  • Two user names same email, forgotten password link...

    Today I signed up and created an account. I realized only after signing up that I had previously created an account (w/same email). I am trying to get the lost password to my original account /user name, however, after multiple attempts requesting "forgotten password" the reset password keeps linking to today's account. How do I resold this and utilize my original (old user name)?

    Hi Raj,
    Is this the only workflow which is not working?
    Three important things you need to consider....
    1. Workflow config in SWU3
    2. Authorizations for your workflow user id
    3. Any number ranges which need to be configured.

  • HT204291 How can I find password to Apple TV? I have forgotten password and need it to activate AirPlay. Thanks!

    How can I find password to Apple TV? I have forgotten password and need it to activate AirPlay. Thanks!

    Welcome to the Apple community.
    Which password is it that you are looking for. If it is your airplay password, simply turn the password off in the airplay settings on the Apple TV and then turn it back on again and enter a new password.

  • I just rented a film using my apple TV and was then asked to enter a code - which I haven't been asked for in long time. I have forgotten the code. Any quick solutions to the problem?

    I just rented a film using my apple TV and was then asked to enter a code - which I haven't been asked for in long time. I have forgotten the code. Any quick solutions to the problem?

    Hello anetsa
    It sounds like you have restrictions setup on your Apple TV. If you do not know your passcode to unlock it, then you will need to restore your Apple TV. Check out the articles below for more information about Restrictions as well as restoring your Apple TV.
    Apple TV: Understanding Restrictions (parental controls)
    http://support.apple.com/kb/HT200198
    Apple TV (2nd and 3rd generation): Restoring your Apple TV
    http://support.apple.com/kb/HT4367
    Regards,
    -Norm G.

  • "Forgotten Password" functionality in E-Commerce 7.0 B2C webshop

    Hi gurus,
    Could anyone let me know if SAP has provided a standard Forgotten Password functionality in the E-Commerce version 7.0 B2C webshop solution ?
    Regards,
    Ashok.

    Hello Ashok,
    As far as i am aware this has remained the same since release 5.0
    regards
    Mark
    Edited by: Mark Foley on Oct 5, 2009 7:20 PM

  • I reset my forgotten password via email on my computer, but 2 hours later new passowrd doesn't work from iPhone  What am I missing?

    I reset my forgotten password via email on my computer.  Two hours later still cannot use new password on my iPhone 5 ios 7.x.x.  Am I missing something?

    Try going to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • I have recently updated to ios5 and when restoring apps etc it says my backup needs a password, i password that i cannot for the life of me remember...is there any 'forgotten password' option available for the backup please?

    i have recently updated to ios5 and when restoring apps etc it says my backup needs a password, a password that i cannot for the life of me remember...is there any 'forgotten password' option available for the backup please?
    i'm desperately in need as EVERYTHING my life revolvesaround is on there

    i have recently updated to ios5 and when restoring apps etc it says my backup needs a password, a password that i cannot for the life of me remember...is there any 'forgotten password' option available for the backup please?
    i'm desperately in need as EVERYTHING my life revolvesaround is on there

Maybe you are looking for

  • How to install BIDS for SQL Server 2008 R2 and Visual Studio 2008(SSRS,SSIS)

    Hi, I want to install SQL Server 2008 R2 and Visual Studio to use SSRS tool, where to download these application. And my System Configuration is Window 8.1,64 Bit. Please share step by step information to download and installation. Kindly Reply soon.

  • Table statistics

    Greetings All, Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production Windows 2008 R2I had 18 unexplained columns appear on a table in one of the schemas. The column names are like SYS_000080$, SYS_000079$, ... Anybody know if g

  • KM-Uploaded Package does not shows up in pending imports list

    Hi All, I have uploaded the package for KM transport and can see in server SYS\global\config\cm\expimp location. But the import is not listed in pending imports to further with the KM transport. SOme one please help quickly. I  need to send transport

  • YouTube help needed

    My YouTube app will not work always says cannot connect to youtube, I need help

  • Link List

    Im trying to print a linked list. The problem im having is this list keeps re-printing its self and crashing. My method looks like this: public void printList() if(isEmpty()) System.out.println("Empty " + ListName); return; System.out.println(ListNam