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 3 of 3

Thread: Problem with JavaMail... HELP! :(

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Problem with JavaMail... HELP! :(

    Hi,

    Please somebody help me. I'm programming a Java Room Booking application where the user is required to give details... with an email address being one of them. I want the send an email to the address given as a receipt.

    Anyway, it's not working for some reason and I have no idea why. Any help would be great!
    Feel free to suggest anything as I'm desperate.
    Thanks

    public static void sendMail(String e) 
    	{
    			final String SMTP_HOST_NAME = "smtp.gmail.com";
    			final int SMTP_HOST_PORT = 465;
    			final String SMTP_AUTH_USER = "";
    			final String SMTP_AUTH_PWD  = "";
     
    			Properties props = new Properties();
    			props.setProperty("mail.transport.protocol", "smtp");
    			props.setProperty("mail.host", "smtp.gmail.com");
    			props.setProperty("mail.user", "");
    			props.setProperty("mail.password", "");
    			System.out.println("One");
     
    		try
    		{
    			Session mailSession = Session.getDefaultInstance(props, null);
    		    Transport transport = mailSession.getTransport();
     
    		    MimeMessage message = new MimeMessage(mailSession);
    		    message.setSubject("Room Booking Confirmation");
    		    message.setContent("This is a test", "text/plain");
    		    message.addRecipient(Message.RecipientType.TO,
    		           new InternetAddress(e));
    		    System.out.println("Two");
    		    transport.connect(SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD);
    		    transport.sendMessage(message,
    		          message.getRecipients(Message.RecipientType.TO));
    		    System.out.println("Three");
    		    transport.close();
    		}
    		catch (MessagingException ex)
    		{
    		    System.out.println(ex);
    		}
    	}
    Last edited by helloworld922; March 17th, 2010 at 11:21 PM. Reason: Please use [code] tags


  2. #2
    Junior Member
    Join Date
    Jan 2010
    Posts
    11
    Thanks
    0
    Thanked 3 Times in 2 Posts

    Default Re: Problem with JavaMail... HELP! :(

    do you get any exceptions at all

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with JavaMail... HELP! :(

    Well, I'm getting a nosuchprovider exception invalid protocol null

Similar Threads

  1. Javamail attachment filenames
    By johniem in forum Java Theory & Questions
    Replies: 0
    Last Post: February 3rd, 2010, 07:51 AM
  2. Javamail
    By johniem in forum Java Theory & Questions
    Replies: 1
    Last Post: February 3rd, 2010, 07:42 AM