The integration of pakages javax.mail in J2SE
hello
Whatever one can help me to integrate javax.mail in J2SE, knowing that I have all the necessary jar files (activation.jar, pop3.jar, mail.jar) and that I was to put them in class path..
thank you
Hi
Try the following as a 'fix' of sorts.....
Copy the .jar files into the directories /lib and jre/lib/ext
This should enable your program to compile and run without problem.
HOWEVER, this is not ideal...you should follow the advice of the previous reply, and explicitly set the classpath during both compilation and runtime exection of your program as a best practice, otherwise you will find yourself in the frustrating position of trying to debug your environment should you try to deploy your program onto another system in the future!!!
Similar Messages
-
Javax.mail.mailexception while am trying to send the mail
Hi.
Am trying to send a mail from ADF Application am using SMTP Server to send the mail
I have added javamail.jar in my libraries
This is the code am using to send
public String send() {
// Add event code here...
String to;
to = new String();
String host = "localhost";
String from = "[email protected]";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
try{
MimeMessage message = new MimeMessage (session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress("to"));
message.setSubject(subj);
message.setText(body);
Transport.send(message);
System.out.println ("Sent Message Successfully");
catch(MessagingException max){
max.printStackTrace();
return null;
}Am getting the exception as below
javax.mail.MessagingException: [EOF]
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1481)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1512)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1321)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:637)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at view.SendMail.send(SendMail.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
Could any one pls help me?
regards,
Prasad K T.This question is better asked in a java forum or JavaMail forum {forum:id=975}
Timo -
Error: Javax.mail does not exist, please help
I have copies mail.jar and activation.jar in the classpath directory as instructed, then try to compile but got the below error: package javax.mail does not exist
please help.
G:\CRD>javac SendMailBean.java
SendMailBean.java:22: package javax.mail does not exist
import javax.mail.*; //JavaMail packages
^
SendMailBean.java:23: package javax.mail.internet does not exist
import javax.mail.internet.*; //JavaMail Internet packages
^
SendMailBean.java:43: cannot resolve symbol
symbol : class Session
location: class SendMailBean
Session l_session = Session.getDefaultInstance(l_props, null);
^
SendMailBean.java:43: cannot resolve symbol
symbol : variable Session
location: class SendMailBean
Session l_session = Session.getDefaultInstance(l_props, null);
^
SendMailBean.java:48: cannot resolve symbol
symbol : class MimeMessage
location: class SendMailBean
MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
^
SendMailBean.java:48: cannot resolve symbol
symbol : class MimeMessage
location: class SendMailBean
MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
^
SendMailBean.java:50: cannot resolve symbol
symbol : class InternetAddress
location: class SendMailBean
l_msg.setFrom(new InternetAddress(p_from)); // Set the From address
^
SendMailBean.java:53: package Message does not exist
l_msg.setRecipients(Message.RecipientType.TO,
^
SendMailBean.java:54: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_to, false));
^
SendMailBean.java:57: package Message does not exist
l_msg.setRecipients(Message.RecipientType.CC,
^
SendMailBean.java:58: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_cc, false));
^
SendMailBean.java:62: package Message does not exist
l_msg.setRecipients(Message.RecipientType.BCC,
^
SendMailBean.java:63: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_bcc, false));
^
SendMailBean.java:68: cannot resolve symbol
symbol : class MimeBodyPart
location: class SendMailBean
MimeBodyPart l_mbp = new MimeBodyPart();
^
SendMailBean.java:68: cannot resolve symbol
symbol : class MimeBodyPart
location: class SendMailBean
MimeBodyPart l_mbp = new MimeBodyPart();
^
SendMailBean.java:72: cannot resolve symbol
symbol : class Multipart
location: class SendMailBean
Multipart l_mp = new MimeMultipart();
^
SendMailBean.java:72: cannot resolve symbol
symbol : class MimeMultipart
location: class SendMailBean
Multipart l_mp = new MimeMultipart();
^
SendMailBean.java:83: cannot resolve symbol
symbol : variable Transport
location: class SendMailBean
Transport.send(l_msg);
^
SendMailBean.java:98: cannot resolve symbol
symbol : class MessagingException
location: class SendMailBean
} catch (MessagingException mex) { // Trap the MessagingException Error
^
19 errorsAnother person who doesn't understand how to set CLASSPATH.
Move those JARs into the same directory as your SendMailBean.java and do it like this:
javac -classpath .;mail.jar;activation.jar -d . *.java
java -classpath .;mail.jar;activation.jar SendMailBeanRead how to set CLASSPATH properly:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html -
Problem importing javax.mail.*
Hey,
I just installed the Java JDK 6 update 16 (windows platform). I am not able to compile a sample code that used the javax.mail package. I am not able to get past the
import javax.mail.*;
line. The compiles says "package javax.mail does not exist"
I tried separately installing the JavaMail 1.4.2 API and setting the classpath to the mail.jar file as suggested in the readme.txt for this API, but I still get the same problem. Anyone has any suggestions?
Thanks!Hi! I see you've answered similar problems before - but nothing seems to be working for me.
My OS is Vista. I installed the JDK 6 update 16 just yesterday. I'm using the command line javac.
I can see the mail.jar file in this folder: C:\Sun\SDK\lib\ and I've set the classpath using : set classpath=%classpath%;C:\Sun\SDK\lib\mail.jar
When I type set classpath at the prompt, I can see that the classpath has been set correctly.
Please help! -
Import javax.mail.* problem ...
I have added the line 'import javax.mail.*;' to the top of my program and got the compiler error 'Package javax.mail not found in import'. I have since read through loads of similar problems on this forum and have tried the following :-
Downloaded jaf-1_0_2.zip and javamail-1_3.zip from the Sun site, unzipped them, and placed mail.jar and activation.jar onto my PC. I have added these .jar files into my classpath and re-booted my PC. However, I STILL get the same compiler message and it's doing my head in! Do I somehow need to add the .jar files into my project? Or am I just being very thick? I am developing using Visual Cafe 3.0. I am using JDK 1.2.2.
I am quite new to this and I have not even started to code the e-mailing method yet - I'm simply trying to get the import working.
Any help would be much appreciated and would mean I can sleep tonight!
Thanks in advance.Hi,
check where you have placed the mail.jar file.....give the proper classpath where you have placed the jar file....
check this out....it will compile... -
Javax.mail.internet.MimeMessage not found
Error message - Cannot find the class file for javax.mail.internet.MimeMessage. Fix the build path then try building this project
I am getting this error message I am uisng jdk 1.6 what additional jar should I add ?[http://www.google.com/search?hl=en&q=javax.mail.internet.MimeMessage+jar+download]
-
My machine is on the DNS and does not require authentication to send e-mail. It also can send and recieve e-mail from the outside world with no problems; however this is the error I see in the logs:
2003-12-11 10:03:49,151 INFO org.dspace.app.webui.servlet.RegisterServlet @ anonymous:session_id=8E5A9C16A74EAA9F334FF566CB6714BF:error_emai$
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 550 5.7.1 <[email protected]>... Relaying denied
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at org.dspace.core.Email.send(Email.java:259)
at org.dspace.eperson.AccountManager.sendEmail(AccountManager.java:291)
at org.dspace.eperson.AccountManager.sendInfo(AccountManager.java:251)
at org.dspace.eperson.AccountManager.sendRegistrationInfo(AccountManager.java:96)
at org.dspace.app.webui.servlet.RegisterServlet.processEnterEmail(RegisterServlet.java:272)
at org.dspace.app.webui.servlet.RegisterServlet.doDSPost(RegisterServlet.java:206)
at org.dspace.app.webui.servlet.DSpaceServlet.processRequest(DSpaceServlet.java:153)
at org.dspace.app.webui.servlet.DSpaceServlet.doPost(DSpaceServlet.java:110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
Can someone tell me what I am doing wrong here?
Thanks.The important line in the stack trace is
javax.mail.SendFailedException: 550 5.7.1 <[email protected]>... Relaying denied
The 550 error is being returned by the SMTP server to the your client as per the RFC.. It tells us that the client has built a message and has pushed it to the server. The server is looking at the message and finds something it doesn't like. It then returns the 500 series error to the client.
The relative locations of the server and client may be an issue since you can configure your server to treat clients run locally different, usually you have the localhost unrestricted and put the filters on for everyone else (there are some admins that lock down local clients on the theory that no one should be running a client on the server so if someone tries they must have hacked the box).
If you try running a different client on the machine with the identical settings for all the header fields you will still get the 550 error. At this point I would have a talk with the admin and ask what the rules for the server are. -
The system doesn’t recognize or capitalize the word (I) or the first word of every sentence. Another really annoying thing about the integrated mail on your Mac computers is the fact that the system learns the word as you type it more and more instead of highlighting it as incorrectly is this is a word that’s being misspelled. Can Apple fix this bug to make it user friendly as if you were using Office or a Word Document?
You hit the target CT.
It’s only fair that if Apple is going to integrate Mail into Mac PCs, it would be nice if the system does it for you like Office or perhaps Outlook. I just don’t to use Outlook although I have it installed and ready to use, but instead use Mail which comes with Mac OS already.
I hope to make some sense here. -
Always get the InternetAddress & javax.mail.Session error
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>
<%@ page import="java.util.*,java.io.*" %>
<%@ page contentType="text/html;charset=big5" %>
<html>
<head>
<title>JavaMail</title>
</head>
<body>
<h2>利用JavaMail來傳送電子郵件 - 附加檔案</h2>
<%
InternetAddress[] address = null;
request.setCharacterEncoding("big5");
// MultipartRequest multi = new MultipartRequest(request , "." , 5*1024*1024 , "big5");
String mailserver = "mail.dwu.edu.tw";
String From = request.getParameter("From");
String to = request.getParameter("To");
String Subject = request.getParameter("Subject");
String type = request.getParameter("Type");
String messageText = request.getParameter("Message");
String FileName = request.getParameter("FileName");
boolean sessionDebug = false;
try {
// 設定所要用的Mail 伺服器和所使用的傳送協定
java.util.Properties props = System.getProperties();
props.put("mail.host",mailserver);
props.put("mail.transport.protocol","smtp");
// 產生新的Session 服務
javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance(props,null);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
// 設定傳送郵件的發信人
msg.setFrom(new InternetAddress(From));
// 設定傳送郵件至收信人的信箱
address = InternetAddress.parse(to,false);
msg.setRecipients(Message.RecipientType.TO, address);
// 設定信中的主題
msg.setSubject(Subject);
// 設定送信的時間
msg.setSentDate(new Date());
if (FileName != null)
File file = new File(FileName);
// 如果有附加檔案時,先將郵件內容部份先存起來
MimeBodyPart mbp1 = new MimeBodyPart();
// 設定郵件內容的型態為 text/plain 或 text/html
mbp1.setContent(messageText, type + ";charset=big5");
// 再來對檔案作處理
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(FileName);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(MimeUtility.encodeText(fds.getName(), "big5", "B"));
// 最後再將二者整合起來,當作一份郵件送出
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
else
// 若沒有檔案時,就直接存郵件內容
msg.setContent(messageText,type + ";charset=big5");
Transport.send(msg);
out.println("郵件己順利傳送");
catch (MessagingException mex)
mex.printStackTrace();
%>
</body>
</html>
==================================
i don't know why i always get the error about the type even i already add the jar file in lib folder:
InternetAddress cannot be resolved to a type
javax.mail.Session cannot be resolved to a typeWhat server are you using?
Did you follow the instructions on the JavaMail FAQ for setting up the server?
Did you restart the server? -
Cannot find the classfile for javax.mail.internet.AddressException
Hi,
Scenario is SAPCRM 7.0/ECC.
We are trying to extend the EmailAction class.
The error bieng faced is
Cannot find the classfile for javax.mail.internet.AddressException.
We have added crm/isa/lwc to the used Dcs but still this error is there.
Mail.jar is also present in the system.
We are not able to make out what exactly the issue is.
Please help.
Thanks,
RohitHi Rohit,
Did you ever find the solution to this problem? We're encountering the same error message.
Thanks!
Joe -
Change the Mail-Session's type in glassfish to type javax.mail.Session
hi all guys!
com.sun.enterprise.deployment.MailConfiguration is the default type of Mail_Session in the glassfish, but I want the javax.mail.Session to construct a MimeMessage!
How can I do?
All comments will be appriciate!It sounds like you are attempting to lookup the resource using the non-portable server dependent resource name (and you are getting a non-portable server dependent result in return).
If instead, you use the portable JNDI name of the mail resource, the expected javax.mail.Session object will be returned, e.g.
Session mailSession = (Session) ic= new InitialContext().lookup("java:comp/env/mail/mobileMailSession");
Also make sure that the resource has been assigned the JNDI name you decide on ("mail/mobileMailSession" in the example above).
See also https://glassfish.dev.java.net/issues/show_bug.cgi?id=4500 and http://forum.java.sun.com/thread.jspa?threadID=5277688&tstart=75 for more information and context. -
Cannot seem to find javax.mail.*
I've been working with J2SE for a while now using version 1.4.2.02
Now i have a new PC and i want to include receiving and sending mail in my applications.
I have downloaded J2SE version 1.4.2_03 and also Javamail 1.3.1
my existing aplications still work fine the problem is in the mail part.
Reading the tutorial by jguru all should work but when compiling i am getting the error that the package javax.mail.* cannot be found.
What did i miss ?
Any help most welcome, thanks.Found it,
need to add the mail.jar file to the classpath itself.
I simply copied it into one of my classpath directories but that's not sufficient. -
Package javax.mail does not exist. Please Help !
Hi all,
I am new to Java and I downloaded some sample application and when I try to compile it, I get an error:
"package javax.mail does not exist".
I've looked through forums and I know something is wrong with CLASSPATHS and that I also have to download the java mail package, but I dont know how to exactly fix this problem. I would appreciate very much if someone could help me, maybe by telling me the steps I need to take.
Thanks.Hey Rom,
Thanks for reply.
The sample application is an authentication module:
http://java.sun.com/j2se/1.4.2/docs/guide/security/jaas/tutorials/GeneralAcnOnly.html
But I think this doesnt really matter, as the error I get is because I have manually added the : import java.mail.*; statement. (Maybe I had to mention it in the previous post). Because I want to add some mail client inside.
I am compiling it using the command: javac, from the commandline menu. -
What is the diffrence between package javax.sql and java.sql
Is javax designed for J2EE?
And when to use package javax?Hi,
What is the diffrence between package javax.sql and java.sql?The JDBC 2.0 & above API is comprised of two packages:
1.The java.sql package and
2.The javax.sql package.
java.sql provides features mostly related to client
side database functionalities where as the javax.sql
package, which adds server-side capabilities.
You automatically get both packages when you download the JavaTM 2 Platform, Standard Edition, Version 1.4 (J2SETM) or the JavaTM 2, Platform Enterprise Edition, Version 1.3 (J2EETM).
For further information on this please visit our website at http://java.sun.com/j2se/1.3/docs/guide/jdbc/index.html
Hope this helps.
Good Luck.
Gayam.Srinivasa Reddy
Developer Technical Support
Sun Micro Systems
http://www.sun.com/developers/support/ -
Problems sending email using javax.mail.*
I need to send an email from an application I am working on. I am using the features of the javax.mail package to do so. In looking at the code I am unsure why this is not working. This is my first time using this package so it might be something silly I am missing so any of your thoughts are appreciated. The code is as follows:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class EmailTester {
public static void main(String[] args) {
try {
//Set the smtp address
Properties props = new Properties();
props.put("mail.smtp.host", args[0] );
// get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
// create a message for this session
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress from =
new InternetAddress( args[1] );
InternetAddress[] to = new InternetAddress[1];
to[0] = new InternetAddress( args[2] );
msg.setFrom(from);
msg.setRecipients(Message.RecipientType.TO, to);
// set the subject and content type
msg.setSubject("subject");
msg.setContent("this is my test email", "text/plain");
// send the email
Transport.send(msg);
catch (MessagingException me) {I have an EMail class that I use at:
http://www.discoverteenergy.com/files/EMail.java
Feel free to use it or compare against your code to see what is different.
Maybe you are looking for
-
Found many threads but all seem old. Tried downloading to a thumb drive from boot cafmp but get an error mssg saying that drivers are no longer available. Any help would be great.
-
Service/maintenance order type SM03 not completely maintained in plant 1000
Dear experts, when I use T-code:iw31 create a service order,It show the following error message: Service/maintenance order type SM03 not completely maintained in plant 1000 Message no. IW216 Diagnosis For the selected order type and plant, no check c
-
Zero Excise duty appeared in J1IIN_Excise Invoice
We are facing issue in excise invoice in domestic sale scenario. We are doing following process- 1) Create sales order VA01 2) Delivery VL01N 3) Billing document VF01 now when we do J1IIN, system shows zero value in BED, Ed Cess and higer ed Cess fie
-
In the past 36 hours I now have a new symbol in the right upper corner of my device which overlays my connections icons. They symbol is a capital ES with a box around it. It appears each time I attempt to reply to a text message. In addition, ever
-
The Msi Z97M Gaming enter on this promotion?
hi. I wonder if this motherboard enters the promotion for Spain putting on this page. game.msi.com/special/cashback-es