Connecting Tech Pros Worldwide Forums | Help | Site Map

about javamail

Familiar Sight
 
Join Date: Jan 2007
Posts: 168
#1: Nov 24 '07
Hello ,

I try a simple javamail program to send a mail.When i execute that javamail program, i got the error as follows


import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class TestEmail {

public static void main(String[] args) {

String to = "roch_libia@yahoo.com";
String from = "libi_jesu@sify.com";
String host = "126.1.1.16";

Properties props = new Properties();

props.put("mail.smtp.host", host);
props.put("mail.debug", "true");
Session s1 = Session.getInstance(props);

try {
Message msg = new MimeMessage(s1);

msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test E-Mail through Java");
msg.setSentDate(new Date());

msg.setText("This is a test of sending a " +
"plain text e-mail through Java.\n" +
"Here is line 2.");

Transport.send(msg);
}
catch (MessagingException mex) {
mex.printStackTrace();
}
}
}//End of class

TestEmail.java:25: cannot access javax.mail.Session
bad class file: C:\javamail-1.4.1\mail.jar(javax/mail/Session.class)
class file has wrong version 48.0, should be 47.0
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
Session s1 = Session.getInstance(props);
^

can u please help to resolve the pbm.(or) give any other suggestion.

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Nov 24 '07

re: about javamail


Which Java version are you using? I guess you have to upgrade.

kind regards,

Jos
Familiar Sight
 
Join Date: Jan 2007
Posts: 168
#3: Nov 26 '07

re: about javamail


Quote:

Originally Posted by JosAH

Which Java version are you using? I guess you have to upgrade.

kind regards,

Jos

Thank u for ur response.Sir, I use the jdk1.3.0_01, javamail-1.4.1, & jaf-1.1.1.


Kind Regards,
Roch
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Nov 26 '07

re: about javamail


Quote:

Originally Posted by rengaraj

Thank u for ur response.Sir, I use the jdk1.3.0_01, javamail-1.4.1, & jaf-1.1.1.


Kind Regards,
Roch

Yep, your jvm version 1.3 is definitely too old. Before you install a package,
always read the README.TXT that comes with it and if possible at least browse
the FAQlist if present. From the FAQlist:

Quote:

Originally Posted by FAQlist

Q: What JDK does the JavaMail API need?
A: The JavaMail API requires JDK/JRE 1.4 or higher. The JavaMail API is a Java optional package, it is not part of the core Java SE but is included in Java EE.

kind regards,

Jos
Familiar Sight
 
Join Date: Jan 2007
Posts: 168
#5: Nov 27 '07

re: about javamail


Quote:

Originally Posted by JosAH

Yep, your jvm version 1.3 is definitely too old. Before you install a package,
always read the README.TXT that comes with it and if possible at least browse
the FAQlist if present. From the FAQlist:



kind regards,

Jos

Thank for ur response Sir.I installed java 1.5.Now the program is compiled successfully.But, when we run the program ,I got the following error

javax.mail.MessagingException: Unknown SMTP host: smtp.yahoo.com;
nested exception is:
java.net.UnknownHostException: smtp.yahoo.com
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTra nsport.java:1389)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SM TPTransport.java:412)


I don't know how to find the host and its address.can we substitute any default IP address.If u Know plz help me.


Kind Regards,
Roch
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#6: Nov 27 '07

re: about javamail


Quote:

Originally Posted by rengaraj

Thank for ur response Sir.I installed java 1.5.Now the program is compiled successfully.But, when we run the program ,I got the following error

javax.mail.MessagingException: Unknown SMTP host: smtp.yahoo.com;
nested exception is:
java.net.UnknownHostException: smtp.yahoo.com
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTra nsport.java:1389)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SM TPTransport.java:412)


I don't know how to find the host and its address.can we substitute any default IP address.If u Know plz help me.


Kind Regards,
Roch

Open a shell (cmd, bsh, ctsh etc.) and ping that host. I just tried it and it exists
(216.109.112.28) but I couldn't use the smtp protocol either to make ik send mail.

The network was simply not available ...

kind regards,

Jos
Reply