#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    13
    Rep Power
    0

    Email confirmation


    hi

    i have created a registration form with an input field of email address.
    now i want if a new user register, it should automatically receive a confirmation mail.

    i have done some coding but i am unable to define what to write on place of highlighted text.

    Please help.

    thanks
    kunal



    public void sendConfEmail(){

    try{

    Properties props = null;

    if (props == null) {
    props = System.getProperties();
    }

    props.put("mail.smtp.host", "<server host name>");

    Session session = Session.getInstance(props, null);

    MimeMessage message = new MimeMessage(session);

    message.setFrom(new InternetAddress("<from email id>"));

    message.addRecipients(Message.RecipientType.To, "<"how to define the recipient here (it should deliver to that address which is newly registered)..">");

    message.setSubject("<Subject of the email>");

    message.setContent("<Content of the email>", "text/plain");

    Transport.send(message);

    logger.info("Sent Email :" +
    "From :" + message.getFrom() +
    "To:" + message.getAllRecipients() +
    "Subject:" + message.getSubject() );

    } catch(Exception ex){
    ex.printStackTrace();
    }
    }
  2. #2
  3. Humble Learner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    280
    Rep Power
    119
    If i understood your question correctly then it should be the email of the newly registered user.

    But why in CC ?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    13
    Rep Power
    0
    thanking you for replying.

    yes it should be the email of the newly registered user.

    and i am sorry its not CC .

    it should be message.recipienttype.to


    public void sendConfEmail(){

    try{

    Properties props = null;

    if (props == null) {
    props = System.getProperties();
    }

    props.put("mail.smtp.host", "<server host name>");

    Session session = Session.getInstance(props, null);

    MimeMessage message = new MimeMessage(session);

    message.setFrom(new InternetAddress("<from email id>"));

    message.addRecipients(Message.RecipientType.to, "<"how to define the recipient here (it should deliver to that address which is newly registered)..">");

    message.setSubject("<Subject of the email>");

    message.setContent("<Content of the email>", "text/plain");

    Transport.send(message);

    logger.info("Sent Email :" +
    "From :" + message.getFrom() +
    "To:" + message.getAllRecipients() +
    "Subject:" + message.getSubject() );

    } catch(Exception ex){
    ex.printStackTrace();
    }
    }


    Any idea How to achieve this.?/

    thanks
    kunal
  6. #4
  7. Humble Learner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    280
    Rep Power
    119
    Are you not storing email of the newly registered user ?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,777
    Rep Power
    348
    This has absolutely nothing to do with using the Oracle database (or SQL at all) and therefor is completely off-topic here.

    Please post this in a Java forum

IMN logo majestic logo threadwatch logo seochat tools logo