Results 1 to 4 of 4
- 06-12-2007, 02:03 PM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 110
- Rep Power
- 0
org.apache.commons.mail.EmailException: Cannot find valid hostname
I'm using the library email of jakarta to send email, but in the method setHostName("") I don't know what I have to put there, and it returns me this
org.apache.commons.mail.EmailException: Cannot find valid hostname
for mail session.Last edited by Ed; 06-12-2007 at 02:21 PM.
- 07-02-2007, 08:02 PM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 119
- Rep Power
- 0
you have to put your host name
I'll give you an example
Java Code:SimpleEmail email = new SimpleEmail(); email.setHostName("mail.myserver.com"); email.addTo("jdoe@somewhere.org", "John Doe"); email.setFrom("me@apache.org", "Me"); email.setSubject("Test message"); email.setMsg("This is a simple test of commons-email"); email.send();
- 07-02-2007, 08:03 PM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 130
- Rep Power
- 0
Go to this page: Commons Email - Examples
- 07-25-2011, 03:19 PM #4
Banned
- Join Date
- Feb 2011
- Posts
- 65
- Rep Power
- 0
hey i tried this code i get some errors.
Java Code:import org.apache.commons.mail.*; public class Main{ public static void main(String[]args) throws EmailException{ Email email = new SimpleEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("user@gmail.com", "*******")); email.setTLS(true); email.setFrom("user@gmail.com"); email.setSubject("TestMail"); email.setMsg("This is a test mail ... :-)"); email.addTo("reciever@live.com"); email.send(); } }is there some thing missing in my library?Java Code:run: Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message at Main.main(Main.java:5) Caused by: java.lang.ClassNotFoundException: javax.mail.Message at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 1 more Java Result: 1
i already add apache.commons.mail
commons-email-1.2.jar
Similar Threads
-
Retreiving of mail body using mail number
By chandu.v09 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-13-2008, 02:25 PM -
IP to HostName
By Java Tip in forum Java TipReplies: 0Last Post: 11-11-2007, 08:07 PM -
Commons Library Framework 0.8.0
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-02-2007, 04:13 PM -
Commons validator
By aczuczor in forum Web FrameworksReplies: 0Last Post: 07-27-2007, 08:46 AM -
Sending a mail with the local mail program
By thedude in forum Advanced JavaReplies: 2Last Post: 07-23-2007, 12:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks