Mail API
I have builded a new project of receving mail,all thing is right before the sentence -messages=inbox.getMessages();I have tested inbox is not null and inbox.exists is true,The pop3 server I using is Domino,Login in procedure is success as server show:
POP3 Server: 192.168.8.123 connected
POP3 Server: new/Dcsoft logged in
But I can nerver get any message from the server and when I add the sentence of getMessages(),an exception will be throwed ,why???
thanks you
next are all error Message
Internal Servlet Error:javax.servlet.ServletException: javax/activation/DataSource
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:399)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
_____________________________________
If you search for more data on this error (and it should be available somewhere) I suspect you may find that activation.jar is missing from the classpath.
Similar Messages
-
Java mail api - sending mails to gmail account
Hello
I am using java mail api to send mails.when i send mails to gmail from ids which are not in gmail friends list, most of the mails are going to spam.Ofcourse, some of them go to inbox.I tried in lot of ways to analyse the problem.But nothing could help. Can anyone plzz tell me how to avoid mails going to spam in gmail, using java mail api?
Thank you in advance,
Regards,
Aradhana
Message was edited by:
Aradhanaam using the below code.
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port","25");
props.put("mail.smtp.auth", isAuth);
Authenticator auth = new UserAuthenticator();
// Get session
Session s = Session.getDefaultInstance(props,auth);
// Define message
Message m = new MimeMessage(s);
// setting message attributes
try {
m.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
InternetAddress f_addr=new InternetAddress(from);
f_addr.setPersonal(personalName);
m.setFrom(f_addr);
m.setSubject(subject);
m.setSentDate(new Date());
m.setContent(msg,"text/plain");
m.saveChanges();
// send message
Transport.send(m);
Message was edited by:
Aradhana -
How can i access gmail's smtp server using java mail api
i m using java mail api to access gmails pop and smtp service to receive and send mail from ur gmail account. I m able to access gmails pop server using the ssl and port 995 , but i can not use its smtp server to which i m connecting using ssl on 465 port. It requires authentication code.
if anybody can help me in this regard i m thnkful to him/her.
thnks in advance.
jogin desaiHere's an example of using SSL + Authentication
http://onesearch.sun.com/search/onesearch/index.jsp?qt=ssl+authentication&subCat=siteforumid%3Ajava43&site=dev&dftab=siteforumid%3Ajava43&chooseCat=javaall&col=developer-forums -
Error while sending mail when using Java Mail API
Hi Experts,
I am trying to execute a webdynpro application which uses the Java Mail API to send emails. The exception that I get on executing the application is :
Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
Can anybody please help me sort out the issue.
Regards
AbdullahHi,
Usually one get this error if the SMTP server is configured not to relay mails (a security measure) or the SMTP server need the mail to be sent from a trusted IP or with proper authentication. Some SMTP servers are configured to block junk mails.
Pls check with your mail server administrator.
Regards -
Save Attachment from exchange server 2010 from oracle using java mail API
Hello,
I want to read email from microsoft exchangeserver 2010 and save attachement into a folder.I created an Java program to import attachments from a exchange server mailbox using "POP3S".It works fine when run as a java application.But when i put this inside Oracle11g R2 using load java and while executing from a procedure it gives an error at parsing message into Multipart
Error at line : Multipart mp = (Multipart)m.getContent();
Error:
Content-Type: multipart/mixed;
boundary="_002_A0C2E09A..................................."
java.lang.ClassCastException
at mailPop3.checkmail(mailPop3:71)
My Java Class is as follows,
import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Date;
The function i used to check for attachments is given below.
public static boolean hasAttachments(Message m) throws java.io.IOException, MessagingException
Boolean hasAttachments = false;
try
// if it is a plain/html text - no attachements
if (m.isMimeType("text/*"))
return hasAttachments;
else if (m.isMimeType("multipart/alternative"))
return hasAttachments;
else if (m.isMimeType("multipart/*"))
Multipart mp = (Multipart)m.getContent();
if (mp.getCount() > 1)
hasAttachments = true;
return hasAttachments;
catch (Exception e) {
e.printStackTrace();
} finally {
return hasAttachments;
My Java Details as follows
java Version :1.5.0_10
java.vm.specification.version:1.0
java.vm.version :1.5.0_01
java.specification.version:1.5
java.class.version:48.0
Java mail API:javamail-1.4.4
Used Jars:mail.jar
Could someone explain why I am getting this error? What can I do to resolve this error?
Is any other Jar need other than mail.jar?
Any help would be much appreciated.
Regards,
NisanthHai EJP,
Thanks for your reply,
My full java class as follows,
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Part;
import javax.mail.Multipart;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeMessage;
public class Newmail
public Newmail()
super();
public static int mailPOP3(String phost,
String pusername,
String ppassword)
Folder inbox =null;
Store store =null;
int result = 1;
try
String host=phost;
final String username=pusername;
final String password=ppassword;
System.out.println("Authenticator");
Authenticator auth=new Authenticator()
protected PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(username, password);
System.out.println("Certificate");
String filename="D:\\Certi\\jssecacerts";
String password2 = "changeit";
System.setProperty("javax.net.ssl.trustStore",filename);
System.setProperty("javax.net.ssl.trustStorePassword",password2);
Properties props = System.getProperties();
System.out.println("host-----"+props);
props.setProperty("mail.pop3s.port", "993");
props.setProperty("mail.pop3s.starttls.enable","true");
props.setProperty("mail.pop3s.ssl.trust", "*");
Session session = Session.getInstance(props,auth);
session.setDebug(true);
store = session.getStore("pop3s");
System.out.println("store------"+store);
store.connect(host,username,password);
System.out.println("Connected...");
inbox = store.getDefaultFolder().getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
Message[] msgs = inbox.getMessages();
System.out.println("msgs.length-----"+msgs.length);
result = 0;
int no_of_messages = msgs.length;
for ( int i=0; i < no_of_messages; i++)
System.out.println("msgs.count-----"+i);
System.out.println("Attachment....>"+msgs.getContentType());
Multipart mp = (Multipart)msgs[i].getContent();
System.out.println("Casting Success" + mp.getContentType());
catch(Exception e)
e.printStackTrace();
finally
try
if(inbox!=null)
inbox.close(false);
if(store!=null)
store.close();
return result;
catch(Exception e)
e.printStackTrace();
return result;
Please check it
Regards,
Nisanth -
Problem in mail api to print the received date of an email
Do anyone know how to get received date of an email?I am using POP3 server.So while printing the date using getReceivedDate(), getting null pointer exception....So how to get the date?...Anyone know this using headers or something?I want a sample program in mail api of java....
Thanks in advance...There is no logic inside the getReceivedDate() method.It's a pre-defined method i have used.I read somewhere that POP3 server won't give information about date.So it is returning NPE.And there it was suggested to use Received headers or something to get the date of a particular email.I am new to the mail api.So anyone know how to use those Received Headers to read the date of an email?
-
File attachment issue in MimeMessage [Mail API]
Hi,
I tried to attach PDF and XML file in MIME Message of MAIL API. I want attach encoded PDF and XML file with gzip format.
I’m able to attached both the files but its not attached properly and when i tried to retrieved back from MIME Message, I’m getting error.
Error is
java.util.zip.ZipException: oversubscribed literal/length tree
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:92)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at com.asite.supernova.test.CreateReadMimeMessage.ReadMail1(CreateReadMimeMessage.java:145)
at com.asite.supernova.test.CreateReadMimeMessage.main(CreateReadMimeMessage.java:48)
Here my code
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Date;
import java.util.Enumeration;
import java.util.Properties;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.BodyPart;
import javax.mail.Header;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import org.apache.commons.codec.binary.Base64;
import com.sun.istack.internal.ByteArrayDataSource;
public class CreateReadMimeMessage {
public static void main(String[] args) {
CreateMail();
ReadMail1();
public static void CreateMail(){
try{
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties);
Message msg = new MimeMessage(session);
msg.setSentDate(new Date());
Multipart multipart = new MimeMultipart();
BodyPart part1 = new MimeBodyPart();
part1.setFileName("test.pdf");
part1.setHeader("Content-Type", "application/pdf");
part1.setHeader("Content-Encoding", "gzip");
part1.setHeader("Content-ID", "PDF");
//1
compressFile("test.pdf","testpdf.gzip");
String encodedData = new String(getBytesFromFile(new File("testpdf.gzip")));
//1
DataSource ds = new ByteArrayDataSource(encodedData.getBytes(), "application/pdf");
DataHandler dh = new DataHandler(ds);
part1.setDataHandler(dh);
//part1.setText("This is only text data");
BodyPart part2 = new MimeBodyPart();
part2.setFileName("test.xml");
part2.setHeader("Content-Type", "application/xml;");
part2.setHeader("Content-Encoding", "gzip");
part2.setHeader("Content-ID", "XML");
part2.setHeader("Content-Transfer-Encoding", "base64");
//1
compressFile("test.xml","textxml.gzip");
String dataXML = new String(getBytesFromFile(new File("textxml.gzip")));
DataSource ds1 = new ByteArrayDataSource(dataXML.getBytes(), "application/xml");
DataHandler dh1 = new DataHandler(ds1);
part2.setDataHandler(dh1);
multipart.addBodyPart(part1);
multipart.addBodyPart(part2);
msg.setContent(multipart);
msg.writeTo(new FileOutputStream(new File("MIMEMessage.xml")));
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
public static void ReadMail1(){
try{
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties);
InputStream inFile = new FileInputStream(new File("MIMEMessage.xml"));
Message msg = new MimeMessage(session,inFile);
Multipart multipart = (Multipart) msg.getContent();
for (int i = 0; i < multipart.getCount(); i++) {
BodyPart bodyPart = multipart.getBodyPart(i);
Enumeration enumHeader = bodyPart.getAllHeaders();
String fileExt="";
while(enumHeader.hasMoreElements()){
Header header = (Header) enumHeader.nextElement();
System.out.println(header.getName() + ":" + header.getValue());
if(header.getName().equalsIgnoreCase("Content-ID")){
if(header.getValue().equalsIgnoreCase("pdf")){
fileExt=".pdf";
}else if(header.getValue().equalsIgnoreCase("xml")){
fileExt=".xml";
BufferedInputStream inn = new BufferedInputStream(bodyPart.getInputStream());
GZIPInputStream gzin = new GZIPInputStream(inn);
// Open the output file
String target ="File"+i+fileExt;
OutputStream outf = new FileOutputStream(target);
// Transfer bytes from the compressed file to the output file
byte[] buff = new byte[128];
int lent;
while ((lent = gzin.read(buff)) > 0) {
outf.write(buff, 0, lent);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
public static void compressFile(String input,String output) {
try {
// Create the GZIP output stream
OutputStream out = new GZIPOutputStream(new FileOutputStream(output));
out =new BufferedOutputStream(out);
// Open the input file
//FileInputStream in = new FileInputStream(input);
InputStream in = new BufferedInputStream(new FileInputStream(input));
// Transfer bytes from the input file to the GZIP output stream
byte[] buf = new byte[524288];
/*int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
int count;
while((count = in.read(buf, 0, 524288)) != -1) {
System.out.println(new String(buf, 0, count));
out.write(buf, 0, count);
out.flush();
in.close();
// Complete the GZIP file
//out.finish();
out.close();
} catch (Exception e) {
e.printStackTrace();
public static byte[] getBytesFromFile(File file) throws IOException {
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
if (length > Integer.MAX_VALUE) {
// File is too large
System.out.println("File Len : " + length);
// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
offset += numRead;
System.out.println("offset : " + offset);
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file "+file.getName());
// Close the input stream and return bytes
is.close();
return bytes;
}Please help me asap.
Edited by: sabre150 on 10-Feb-2011 01:50
Moderator action : added [ code] tags to make the code readable.String is not a suitable container for binary data so unless the two lines
compressFile("test.pdf","testpdf.gzip");
String encodedData = new String(getBytesFromFile(new File("testpdf.gzip")));actually Base64 encode the file content you are probably corrupting your file.
I suspect you should be Base64 encoding the compressed file and modifying the mime-type to reflect this. -
Hi
We have a requirement to create a custom e mail. For the same I am trying to use Java Mail API.I am facing an issue with the following code:
session session1 = session.getInstance(properties, null);
System gives an error Sourced file: inline evaluation of: ``Properties props = new Properties(); session session1 = session.getInstance(prop . . . '' : Typed variable declaration : Class: session not found in namespace
Is there some specific API i need to import for session class. Kindly suggest.
Regards
ShobhaHi Shobha,
I was also facing the same issue from last couple of weeks and just now i have achieved the working functionality.
Please find below working code and replace values as per your serveru2019s configuration.
import com.sap.odp.api.util.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.File;
import java.net.*;
// SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
String to =<email address>;
String from =<email address>;
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = <smtp host name>;
String user = <smtp user name>;
// Create properties, get Session
// Properties props = new Properties();
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", host);
props.put("mail.debug", "false");
props.put("mail.smtp.auth", "false");
props.put("mail.user",user);
props.put("mail.from",from);
Session d_session = Session.getInstance(props,null);//Authenticator object need to be set
Message msg = new MimeMessage(d_session);
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);
Deepak!!! -
Problem in sending messages using java mail api
Hi All,
I have a problem in sending messages via java mail api.
MimeMessage message = new MimeMessage(session);
String bodyContent = "ñSunJava";
message.setText (bodyContent,"utf-8");using the above code its not possible for me to send the attachment. if i am using the below code means special characters like ñ gets removed or changed into some other characters.
MimeBodyPart messagePart = new MimeBodyPart();
messagePart.setText(bodyText);
// Set the email attachment file
MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fileDataSource = new FileDataSource("C:/sunjava.txt") {
public String getContentType() {
return "application/octet-stream";
attachmentPart.setDataHandler(new DataHandler(fileDataSource));
attachmentPart.setFileName(filename);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messagePart);
multipart.addBodyPart(attachmentPart);
message.setContent(multipart);
Transport.send(message);is there any way to send the file attachment with the body message without using MultiPart java class.Taken pretty much straight out of the Javamail examples the following works for me (mail read using Thunderbird) // Define message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
// Set the 'to' address
for (int i = 0; i < to.length; i++)
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
// Set the 'cc' address
for (int i = 0; i < cc.length; i++)
message.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
// Set the 'bcc' address
for (int i = 0; i < bcc.length; i++)
message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
message.setSubject("JavaMail With Attachment");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("Here's the file ñSunJava");
// Create a Multipart
Multipart multipart = new MimeMultipart();
// Add part one
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
for (int count = 0; count < 5; count++)
String filename = "hello" + count + ".txt";
String fileContent = " ñSunJava - Now is the time for all good men to come to the aid of the party " + count + " \n";
// Create another body part
BodyPart attachementBodyPart = new MimeBodyPart();
// Get the attachment
DataSource source = new StringDataSource(fileContent, filename);
// Set the data handler to this attachment
attachementBodyPart.setDataHandler(new DataHandler(source));
// Set the filename
attachementBodyPart.setFileName(filename);
// Add this part
multipart.addBodyPart(attachementBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send(message); -
Using Java Mail API from Tomcat
Hello,
Purely as an academic exercise I have written a JSP page which, upon being requested from the client's browser, should send me a default email using Java Mail Api.
here is the code :
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class TestMail {
static String msgText1 = "success this time 12";
static String msgText2 = "This is the text in the message attachment.";
public String sendIt() {
String to = "<my email";
String from = "<anything>";
String host = "<my ip address of smtp server>";
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", host);
Session session = Session.getInstance(props, null);
.....The code works fine as a stand alone app but when called from JSP page it hangs on the Session.getInstance line. I can only guess that this might be a security issue with the container not allowing access to the smtp server ?
Can anyone give me a clue ???Your Tomcat log files should spell out the problem for you.
My Tomcat installation does not come with the Java Mail API. I had to add the mail and activation jar files to the server/common.lib directory (or the server's shared/lib or the WEB-INF/lib of your application.)
HTH. -
Problem in retrieving email using java mail api
hi,
In my project,i am retrieving mails from a particular email id.
I am able to retrieve the latest mails and save it in a folder in my system.
The problem is whenever i run the program eventhough the most recently received mail in inbox is retrieved and saved,again it is retrieving the same one and saving it in the same folder(not repeating).
I tried to check the newmessages in the inbox using the folder.hasNewMessage() method in java mail api,but the method is returning false only regardless new mail is there in inbox or not.
I want to read the unread messages only.Dont want to retrieve the already read mails.
I got the mail retrieving code from the below site.(sorry not posting the code because it is so long and having 4 classes)
http://www.builderau.com.au/program/java/soa/Getting_the_mail_in_receiving_in_JavaMail/0,39024620,39228060,00.htm
Can anyone tell me how to read unread mails in the inbox?
Thanks a lothi parvathi
i think your mail program is receving mails using imap
the imap is only receve the mail from server but the pop is deleting the mails after receving
use the following sample code
package com.sfrc.mail.pop;
import javax.mail.*;
import javax.mail.internet.*;
import com.sun.mail.handlers.message_rfc822;
import java.util.*;
import java.io.*;
* Owner: SFRC IT Solutions Pvt Ltd
* Author:Arunkumar Subramaniam
* Date :12-06-2006
* File Name: AttachRecive.java
public class AttachRecive
public static void main(String args[])
try
String popServer="192.168.1.1";
String popUser="pl";
String popPassword="password";
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(popServer, popUser, popPassword);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// Get directory
Message message =folder.getMessages();
Multipart mp = (Multipart)message.getContent();
for (int i=0, n=mp.getCount(); i<n; i++) {
Part part = mp.getBodyPart(i);
String disposition = part.getDisposition();
// Close connection
folder.close(false);
store.close();
catch (Exception ex)
System.out.println("Usage: "
+" popServer popUser popPassword");
System.exit(0);
Regards
Arunkumar Subramaniam
SFRC IT Solutions Pvt Ltd
Chennai -
Java.lang.UnsupportedClassVersionError while using java mail api
Hi Everybody ,
I am new comer to this forum , and would like to be an active member.
I am getting this error while trying to use the java mail api to send an email using smtp.
The error is as follows :
Exception in thread "main" java.lang.UnsupportedClassVersionError: javax/mail/Message (Unsupported major.minor version 48.0)
Can Anyone please tell where I am wrong.
I am using the following code
==============================================================
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.abc.com");
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Optional : You can also set your custom headers in the Email if you Want
msg.addHeader("MyHeaderName", "myHeaderValue");
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
==============================================================Hi Philip ,
Thanks for the prompt reply , I had installed oracle client services which overid my jdk1.4 installation with jdk1.3 and hence the error. I changed my classpath settings to point to jdk1.4 and it owrked properly.
Thanks once again.
regards,
Rupesh Rajan -
Oracle Java Mail API exception in Jdev 11.1.15
we are using java mail api to send out emails. and wrap it in java embedding with in our webservice.
we are using jdeveloper 11.1.1.5 for this and the Java API is failing with the below error, we have included all the java libraries. As code is working fine in Jdeveloper 11.1.2
we tried different version of jdeveloper ( 11.1.1.5, 11.1.1.7 ) but its still the same. Can some one please suggest
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at bts.mail.SendMailTLS.main(SendMailTLS.java:50)
Caused by: javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420)
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)
at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384)
at javax.mail.Service.connect(Service.java:297)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at bts.mail.SendMailTLS.main(SendMailTLS.java:45)Can Some body help me with this please
-
I currently downloaded the appropriate programs to use the Mail api however when i compile the messagesend in the demos folder i get an error saying javax.mail does not exist. I'm also having a problem setting up my class path in Systems/Evirnonment. My current path is ;d:\IBMVJava\eab\runtime30;d:\IBMVJava\eab\runtime20;d:\jsdk2.1;d:\jsdk2.1\servlet.jar;d:\jsdk2.1\server.jar;d:\oracle\ora81\jdbc\lib\classes12.zip;d:\ol304\learning;d:\ol316\Support\servlet.jar;%ol311_root%;%ol311_root%\ch06;%ol311_root%\ch07;%/TOMCAT_HOME%\lib\servlet.jar\ Where in this path do in insert ".;D:\Java\javamail-1.2\mail.jar;D:\Java\jaf-1.0.1\activation.jar".
Thanks for the classpath information regarding the .jar files. Now when I start tomcat cat it runs appropriately. However I am still having a problem when i try to compile the message send demo. The message I get is javax.mail does not exist,(import javax.mail.) when I downloade the mail api I placed on the root of my D drive and i placed the mail and activation jar files in my lib folded of my Jakarta-3.2.1 lib folder. I graduated Chubb Institute back in october and am currently still looking for work so my memory but be a little fuzzy as to whether or not this is correct. Your help is greatly appreciated.
-
Java mail api: SendFailedException when trying to send Mail via SMTP
Hello,
I'm trying to send a mail via java mail api using a server that requires smtp authentication.
I'm currently using the following code:
protocol = "smtp";
host = "auth.smtp.profimailer.de";
port = 25;
String from="[email protected]";
String to="[email protected]";
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
Authenticator auth = new PopupAuthenticator();
session=Session.getInstance(props,auth);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from,"[email protected]"));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to,"ToName"));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
Transport.send(message);
static class PopupAuthenticator extends Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("e12345676", "mypass");
}When trying to run this code, I get the following exception:
D:\eclipse30RC1\workspace\ClassifyIt\bin>java -cp .;../lib/javamail.jar de.jwannenmacher.classify.TestMail > test.txt
javax.mail.SendFailedException: Send failed;
nested exception is:
javax.mail.SendFailedException: Sender "[email protected]" <jens
@jens-wannenmacher.de> was rejected: 501
at javax.mail.Transport.doSend(Transport.java:223)
at javax.mail.Transport.send(Transport.java:92)
at de.jwannenmacher.mail.pop3client.POP3Client.getAllNewMessages(POP3Cli
ent.java:176)
at de.jwannenmacher.classify.TestMail.main(TestMail.java:22)
Any suggestions on this?
Thanks and best regards,
JensHi,
yes smtp is a standard and I think you could use this with almost every smtp server.
If your smtp server doesn't require authentication you can access it without an authenticator
I think...
Best regards,
Jens -
String "iso-8859-1" found in subject line of java mail API(when German char
We have written a mail client using java mail API and it works fine. Some body sends the email with subject line contains German chars(using some other mail client like outlook)
and our mail client is running on the machine whose Local has been set 'German'.
Now, while getting the subject line
Javax.mail.Message email; //local variable
// some how I am intializing email.
String str = email.getSubject();
the value of str returns "Bitte die 4 Items I�schen. Kein Bedarf. Ich kann die=?iso-8859-1?Q?_L=F6schung_nic?="
but actual value subject line was "Bitte die 4 Items I�schen. Kein Bedarf. Ich kann die L�schung nic"
So '�' char was repalced by some arbit chars.
Moreover, Charset.defaultCharset().name() returns 'windows-1252'
Please suggest me how I can get the actual subject line
Thanks
-Sanjeevhttp://forum.java.sun.com/thread.jspa?threadID=741111&messageID=4250621
visit it
by ghanshyam
Maybe you are looking for
-
How to Convert 44.1 to 48k in the timeline
Working on FCP 5 I imported a couple of music cues iat 44.1. Is there a quick and easy way to convert these tracks to 48K without leaving the project? Thanks
-
ICON on HR Infotypes(urgent)
hi all, i have to provide ICON on all the HR Infotypes. so how i can do this. plz give me solution. i will award ur efforts for this thanks
-
Hello! I purchased "The Long Tail" from the iTunes Store. All 4 parts of it play in iTunes but part 4 will not play on my Nano 2G. I have scrubbed and reset it with no joy. When I select the track after a brief pause it will just skip onto the next t
-
Assignment of material handling group to business location
Hi, I am getting an error while entering meter in Location Master through O402. Please guide where to assign material handling group to business location. Thanks & Regards, Komal
-
I have downloaded and installed the new ios7 software on my iphone 4s but im having trouble getting through the activation process i keep getting the message "iphone could not be activated because the activation server cannot be reached"? any suggest