views:

279

answers:

3

Would someone please be able to explain to me how to properly install JavaMail and have it to execute in Eclipse please.

I have been trying for the past few hours and I am completely lost as to why this is.

This is from trying to execute their demo projects msgsend.java and msgshow.java.

I either find an error message stating invalid protocol or could not connecto to SMTP host: localhost, port 25;

A: 

What I suggest.

  1. Open Eclipse
  2. Create a new Java project
  3. Create a new Java class which contains a main method (entry point)
  4. Create a folder "libs" inside which you put your JavaMail jar library and other external dependencies
  5. Right-click (from within eclipse) on the added JavaMail jar file and choose Build path and add to build path.
  6. Now you project should be ok in terms of dependencies and you can start coding your test logic within your main method or other classes you create
  7. Once coded, Run your project, by right-clicking on the class which represents your app's entry point and select Run and run as Java application

(That's all I can provide given the details in your question ;) )

Juri
Oh my goodness this worked! I have a feeling that I was just having problems with the command line aspect and me going on to create a proper class with methods resulted in this actually working. Very helpful and I appreciate it dearly, thank you
JackSparrow
A: 

If you're running the examples and it's using "localhost:25" as the server, you'll need to have an SMTP server running on the same machine.

If you don't have a local SMTP server, then try replacing "localhost" with the SMTP server hostname that your ISP provides you.

Marcus Adams
A: 

If you are getting an exception being thrown which is stating that it could not correct to an SMTP host (it may be helpful if you posted the exact error) that means that Javamail is correctly installed in your classpath but that it could not find the given SMTP host.

Keep in mind that by merely dropping Javamail into Eclipse will not automatically result in an SMTP server running on localhost (aka your own machine).

So, either set up an SMTP server on your machine or just use your ISP's server for test purposes.

I would suggest the later, but if you are interested in the former, you may want to check out: http://www.ericdaugherty.com/java/mailserver/

It includes an Eclipse plugin.

Avrom
Speaking on this, how does this differ from that say of greenmail? My Aim is to test spam emails with a spam filter, would the server you posted allow me to carry this process out without being flagged?
JackSparrow