Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: sending email

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post sending email

    hi friends, i want to send mail by using jsp and servlet...can u please help me?? can u tell me code to do that?? wat will be server settings for that??


  2. #2
    Junior Member
    Join Date
    Apr 2014
    Posts
    22
    My Mood
    Lonely
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: sending email

    Please put this in the right forum...
    Thanks.
    The forum "Java Networking" will try to help you .
    If you put it over there and make an effort in posting you will get help.
    Also read this.
    Im just trying to help

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post email sending in java

    hi friends i want to send a mail by using java...
    i have written below code but its not working...
    String to = "onkar.gosavi@ahilane.com";

    // Sender's email ID needs to be mentioned
    String from = "thite.pradip57@gmail.com";

    // Assuming you are sending email from localhost
    String host = "localhost";

    // Get system properties
    Properties properties = System.getProperties();

    // Setup mail server
    properties.setProperty("mail.smtp.host", host);

    // Get the default Session object.
    Session session = Session.getDefaultInstance(properties);

    try{
    // Create a default MimeMessage object.
    MimeMessage message = new MimeMessage(session);

    // Set From: header field of the header.
    message.setFrom(new InternetAddress(from));

    // Set To: header field of the header.
    message.addRecipient(Message.RecipientType.TO,
    new InternetAddress(to));

    // Set Subject: header field
    message.setSubject("This is the Subject Line!");

    // Now set the actual message
    message.setText("This is actual message");

    // Send message
    Transport.send(message);
    System.out.println("Sent message successfully....");
    }catch (MessagingException mex) {
    mex.printStackTrace();
    }


    can u tell what will value of host???

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: sending email

    Duplicate threads merged.

Similar Threads

  1. Re: sending email to outlook
    By Hiral in forum Java Networking
    Replies: 1
    Last Post: November 4th, 2012, 10:40 AM
  2. Exception while sending Email.
    By hashitagarwal in forum Exceptions
    Replies: 1
    Last Post: September 13th, 2012, 12:50 AM
  3. sending email to outlook
    By cnjiru in forum Java Networking
    Replies: 2
    Last Post: July 31st, 2012, 09:05 AM
  4. Trouble sending an email from my program
    By java99 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 11th, 2012, 05:27 PM
  5. Sending an email of the results from 1 Class to another
    By Laxman2809 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 20th, 2011, 08:56 PM