473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

about javamail

168 100+
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.
Nov 24 '07 #1
5 2386
JosAH
11,448 Expert 8TB
Which Java version are you using? I guess you have to upgrade.

kind regards,

Jos
Nov 24 '07 #2
rengaraj
168 100+
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
Nov 26 '07 #3
JosAH
11,448 Expert 8TB
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:

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
Nov 26 '07 #4
rengaraj
168 100+
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
Nov 27 '07 #5
JosAH
11,448 Expert 8TB
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
Nov 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jonatan Fernstad | last post by:
I am using the JavaMail API to send email. It seems the Message.setSentDate(new Date()) sets wrong time zone. I am at GMT+1, and this is also what the new Date() is showing. But when the...
0
by: pcouas | last post by:
Hi, Anyone know how reading Outlook or Outlook express contact File from Javamail ? It seems theses files are named .dbx and .vba Thanks Philippe
1
by: Daniel Albisser | last post by:
Hi @ll, I was wondering why I lose the connection to the mail store while retrieving information from it without calling the method store.close()! At the end I found out that the method...
0
by: Volker Jahns | last post by:
hi together. public void sendMail(String body, String subject, String sender, String to, String copy) { String server = "srv.domain.com"; String toList = null; Properties props = new...
0
by: John P | last post by:
Hello, I'm building email messages and attachments via the JavaMail API, which are then sent via sendmail. The attachments are mime attachments of type "application/octet-stream". They are...
1
by: Jeff | last post by:
I'm finding that as I loop through a large pop store and reading each message into an input stream that the JVM is running out of memory for the case where the pop store is large (several thousand...
1
by: Joshua | last post by:
Ive playedw ith the standard pop3 and imap and nntp and smtp modules but am unconvinced -- I would like to find a more sophisticated email handling API like JavaMail (from which I hope to convert)....
0
by: sandeepk84 | last post by:
Hi all... I am facing a problem in getting attachments from Yahoo Classic using JavaMail. My program reads the attachments from gmail and Yahoo Beta. But attachments of type pdf or txt from...
0
by: libia | last post by:
Hello, I want to send a mail using java program .so i used javamail 1.4 and jaf 1.1.It was compiled successfully.If i run the program it gives the error that "unable to connect" to port 25.If...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.