Javax.mail.MessagingException: 502 unimplemented (#5.5.1)
hi,
I am facing a problem in sending mail.
My program is running on a linux operating system and Tomcat 5.5 .
So my problem is that when I try to execute that program I get the
FOLLOWING EXCEPTION.
I am not getting why that exception is occuring.
javax.mail.MessagingException: 502 unimplemented (#5.5.1)
at com.sun.mail.smtp.SMTPTransport.issueCommand SMTPTransport.java:1020)
at com.sun.mail.smtp.SMTPTransport.helo SMTPTransport.java:630)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:31 1)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at com.kaizen.Passtori.mail.SendMail.sendMailWithAttachment(SendMail.java:102)
at com.kaizen.Passtori.UserValidation.UserUtility.sampleRegistration(UserUtility.java:680)
at org.apache.jsp.jsp.registrationTake_jsp._jspService(org.apache.jsp.jsp.registrationTake_jsp:431)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p rocessConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:684)
at java.lang.Thread.run(Thread.java:595)
If anyone knows why this exception is occuring please kindly tell me.
Its really urgent.
Thanks and regards
Rakesh Sagar.
Run the code using JavaMail's debug mode to see the conversation between your code and the server.
I don't see the code where you're getting the Session so I can't advise you how to do that, if you don't already know.
Similar Messages
-
Mail doesn't send - javax.mail.MessagingException: 250
Hello all,
I'm new to JavaMail. I actually started with it last night. I've successfully sent a number of messages, but I randomly get a strange exception for no apparent reason.
If I run the exact same code several times, it will produce this error about every 5 or 6 times:
javax.mail.MessagingException: 250 Requested mail action okay, completed
Does anyone know what might be going on? Thanks in advance for any help you might can give.
Here is the heart of my code:
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host1);
// Get session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(fromAddress));
// Set the to address
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
// Set the subject
message.setSubject(subject);
// Set the content
message.setContent(content, "text/html");
// Send message
Transport.send(message);
Below is the debugger output: (certain values have been removed for anonymity's sake)
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG: SMTPTransport trying to connect to host "xx.xx.xx.xx", port 25
DEBUG SMTP RCVD: 220 domain.company.com ESMTP MailEnable Service, Version: 1.704-- ready at 01/14/04 14:07:27
DEBUG: SMTPTransport connected to host "xx.xx.xx.xx", port: 25
DEBUG SMTP SENT: EHLO licensing
DEBUG SMTP RCVD: 502
DEBUG SMTP SENT: HELO licensing
DEBUG SMTP RCVD: 250-AUTH LOGIN
250-SIZE 5120000
250-HELP
250 AUTH=LOGIN
DEBUG SMTP: use8bit false
DEBUG SMTP SENT: MAIL FROM:<[email protected]>
DEBUG SMTP RCVD: 250 Requested mail action okay, completed
DEBUG SMTP SENT: RCPT TO:<[email protected]>
DEBUG SMTP RCVD: 250 Requested mail action okay, completed
Verified Addresses
[email protected]
DEBUG SMTP SENT: DATA
DEBUG SMTP RCVD: 250 Requested mail action okay, completed
DEBUG SMTP SENT: QUITBut I am getting that code thrown as a MessageException; the message never goes through. If you look at the debugging output compared to a message that went through, the DATA transmission commands are screwed up.
Thanks for your input, though. I think I've gotten around this by trying to resend the message. It looks like that when I get this exception the message is never sent. I have a catch that detects this exception and tries to resend up to 3 times.
Thanks,
floosh -
Javax.mail.MessagingException: 505 Client was not authenticated
Hi!,
I got the following error:
Exception in thread "main" javax.mail.MessagingException: 505 Client was not authenticated
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:507)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:312)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:168)
at HelloMail.main(HelloMail.java:35)
This is the code:
To send an email I need authentification, and I include the mail.smtp.auth propertie and
"message.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect("mail.xxx.com.mx","harriaga",passw);
transport.sendMessage(message,message.getAllRecipients());
transport.close();"
Do you know if I am skip something.
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class HelloMail {
public static void main(String args[]) throws Exception {
String host="mail.xxx.com.mx"; //obviously doesn't work
String from="[email protected]"; //sender's email
String to ="[email protected]" ; //receiver's email
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
Session session=Session.getInstance(props,null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));
message.setSubject(" My Test HTML email ");
message.setText(" Here is the content ");
message.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect("mail.xxx.com.mx","harriaga",passw);
transport.sendMessage(message,message.getAllRecipients());
transport.close();
Thanks for all,
HAG.HAG,
you need to create a session object passing a valid authenticator. In other words,
MyAuthenticator auth = new MyAuthenticator ();
Session session = Session.getInstance(props, auth);where MyAuthenticator is something like
public class MyAuthenticator extends Authenticator{
public PasswordAuthentication getPasswordAutentication(){
return new PasswordAuthentication( "user", "password");
}You obviously need to replace username and password with data valid for your e-mail account.
Hope this helps,
gulfi -
Javax.mail.MessagingException: Missing start boundary
I use the following code creates a Mime file
MimeMultipart mmp = new MimeMultipart();
MimeBodyPart mbp = null;
// add rootpart
mbp = new MimeBodyPart();
mbp.setContentID("[email protected]");
mbp.setDataHandler(new DataHandler(new FileDataSource(args[0])));
mmp.addBodyPart(mbp);
// add attachment info
for(int i = 1; i < args.length; i = i+2){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(baos);
FileInputStream fis = new FileInputStream(args[i+1]);
byte[] bytes = new byte[1024];
int len;
while((len = fis.read(bytes, 0, 1024)) > 0){
gos.write(bytes, 0, len);
fis.close();
gos.close();
baos.close();
InternetHeaders ih = new InternetHeaders();
ih.addHeader("Content-ID", args);
mbp = new MimeBodyPart(ih, baos.toByteArray());
mmp.addBodyPart(mbp);
String CarriageReturn = String.valueOf(CARRIAGE_RETURN);
String lineFeed = String.valueOf(LINE_FEED);
String horizontaltab = String.valueOf(HORIZONTAL_TAB);
FileOutputStream fos = new FileOutputStream(args[0] + ".mime");
StringBuffer msgParam = new StringBuffer();
msgParam.append("MIME-Version: 1.0");
msgParam.append(CarriageReturn);
msgParam.append(lineFeed);
msgParam.append("Content-Type: ");
msgParam.append(mmp.getContentType().replaceAll(CarriageReturn,"").replaceAll(lineFeed,"").replaceAll(horizontaltab,""));
msgParam.append("; start=\"<[email protected]>\"");
msgParam.append(CarriageReturn);
msgParam.append(lineFeed);
msgParam.append(CarriageReturn);
msgParam.append(lineFeed);
msgParam.append(CarriageReturn);
msgParam.append(lineFeed);
fos.write(msgParam.toString().getBytes());
mmp.writeTo(fos);
fos.close();
I can correctly read the mime file at windows OS,but in linux OS i got the following error Message:
2010/11/19 11:53:40 K101J2EED1 fatal 0041EBFC124735B5B67FFA9F4B3B09961KD1 例外=[javax.mail.MessagingException: Missing start boundary]
sun.reflect.GeneratedMethodAccessor303.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy28.execute(Unknown Source)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
jp.terasoluna.fw.web.struts.action.RequestProcessorEx.process(RequestProcessorEx.java:149)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:675)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:324)
jp.co.nttdata.erc.sys.app.extended.ExtendedFilter.doFilter(ExtendedFilter.java:163)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:424)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:324)
jp.co.nttdata.erc.sys.app.extended.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:174)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:424)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:324)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:379)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.web.catalina.core.LinkedPipeline.invoke(LinkedPipeline.java:475)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:983)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:349)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.web.tcg.ThreadControlGroupValve.invoke(ThreadControlGroupValve.java:82)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.ejb.management.mbean.web.RequestStatisticsValve.invoke(RequestStatisticsValve.java:72)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:188)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.web.catalina.core.StandardSessionValve.invoke(StandardSessionValve.java:96)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.web.catalina.core.LinkedPipeline.invoke(LinkedPipeline.java:475)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:983)
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:3928)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:261)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:197)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.web.catalina.core.LinkedPipeline.invoke(LinkedPipeline.java:475)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:983)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
com.hitachi.software.web.catalina.core.ValveWrapper.invokeNext(LinkedPipeline.java:672)
com.hitachi.software.web.catalina.core.LinkedPipeline.invoke(LinkedPipeline.java:475)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:983)
org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:700)
org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:959)
java.lang.Thread.run(Thread.java:620)
Edited by: chengen on Nov 24, 2010 8:26 PM
Edited by: chengen on Nov 24, 2010 9:25 PMI can correctly read the mime file at windows OS,but in linux OS i got the following error Message:That would suggest one or more of the following.
1. An end of line problem. Something is wrong with your use of CR/LF.
2. A line length problem (brief look suggests a 998 limit.)
3. One reader is more lenient than the other. This goes back to 1 and 2. -
Javax.mail.MessagingException: 451 Error while writing spool file??
Hi all friends,
Can any one plz tell me why Iam getting below error when Iam trying to send mail with attachment.Iam using Java Mail API.
javax.mail.MessagingException: 451 Error while writing spool file
Plz tell me what are the reasons behind it.
Regards
BikashThe problem here is that the SMTP server was unable to write its spool file.
The error is probably on the OS side of things and has nothing to do with email except that the lack of the system resource is causing email to fail.
Have the server admin take a look at his error log to find out why the the user that smtp is running as could not write the file. -
Javax.mail.MessagingException
HI all,
i am new to this area and currently i am working on email messaging application.
in here i have set up an SMTP server and every thing, but finally it gives following exception
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: 550 Sorry, <[email protected]> is not allowed access from your location
can you please help me to solve this problem
thanx
Kelumhi,
thanx for your reply...i checked JavaMail faq.
it says
This is an error reply from your SMTP mail server. It indicates that your mail server is not configured to allow you to send mail through it.
actually my application is a servlet. that means do we have to give any permisions to my web server to send requests to smtp server.
do you have any idea abot this
thanx
Kelum -
Javax.mail.MessagingException: 451 4.3.2 Please try again later
Hi,
Can any one help out to fix following problem.
exception occurred :Sending failed;
nested exception is:
javax.mail.MessagingException: 451 4.3.2 Please try again laterIf this is generated by the server at random, I do not think javamail can not do anything about it. You can add retry logic in your code or figure out why server is giving this error (configuration issue? need to increase any parameters on the server side?).
-
Reading Inbox - javax.mail.MessagingException: Connect failed;
I get an error message while trying to read emails by connecting to a company mailbox. The message is as follows:
javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: no further information
boolean com.sun.mail.pop3.POP3Store.protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)
void javax.mail.Service.connect(java.lang.String, int, java.lang.String, java.lang.String)
void javax.mail.Service.connect(java.lang.String, java.lang.String, java.lang.String)
void GetMessageExample.main(java.lang.String[])
The code is very simple and as follows:
import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class GetMessageExample {
public static void main (String args[]) throws Exception {
String host = "companyname.com";
String username = "user";
String password = "xxxx";
try{
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
BufferedReader reader = new BufferedReader (
new InputStreamReader(System.in));
// Get directory
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i<n; i++) {
System.out.println(i + ": " + message.getFrom()[0]
+ "\t" + message[i].getSubject());
// Close connection
folder.close(false);
store.close();
} catch (Exception e) {
e.printStackTrace();
I have a two part question:
1. At home I am using a dial-up connection it works when I change the settings to an email account as provided by the local ISP.
I have tried it with both "pop3" and "imap" in
Store store = session.getStore("pop3");
for the company email but it does not work.
Is this a problem with company security? Maybe firewall/proxy error? If so how do I get around it?
2. Also, when I am in the office (LAN used to connect to Internet) I cannot even get a connection to the ISP account - similar problem or different?
Any thoughts and help most appreciated.
Thanks in advance,
MarkIt could be that the mail server is not accepting connections from the machine you are on. Have you tried using Outlook Express or the Netscape email client to connect to the server/account from the machine that is getting the failure?
-
Javax.mail.MessagingException: Unconnected sockets not implemented
Hi,
I am trying to get mails from mail server using IMAP.I am using Jdk 1.5.0.While I am trying to get mails, I am getting following exception.
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
javax.mail.MessagingException: Unconnected sockets not implemented;
nested exception is:
java.net.SocketException: Unconnected sockets not implemented
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
at com.maxis.getmail.receiveEmails(getmail.java:58)
at com.maxis.getmail.main(getmail.java:22)
Caused by: java.net.SocketException: Unconnected sockets not implemented
at javax.net.SocketFactory.createSocket(SocketFactory.java:97)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:225)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
... 3 more
Here is my code..
String host = "host";
String name = "username";
String passwd = "pwd";
java.security.Security.setProperty("ssl.SocketFactory.provider", "DummySSLSocketFactory");
System.setProperty("javax.net.ssl.trustStore"," JAVA_HOME/jre/lib/security/cacert");
// Get a Properties object
Properties props = System.getProperties();
props.setProperty("mail.imaps.ssl.enable", "true");
props.setProperty("mail.imaps.ssl.socketFactory.class","DummySSLSocketFactory");
//props.setProperty("mail.imaps.ssl.socketFactory.fallback", "false");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
Store store = session.getStore("imaps");
store.connect(host,portno ,name, passwd); // exception here
===================================================
I am unable to understand where went wrong. Could someone help me ,Plz?
Any help would be appreciated.
Thanks.There were some bugs in the old instructions for socket factories. Search this forum for the details.
But, you should just upgrade to JavaMail 1.4.3, which supports properties that better control SSL
connections, as well as a MailSSLSocketFactory that will give you more control without having to
write your own. -
Javax.mail.MessagingException: Connection refused: connect on localhost
Hello,
I am using Tomcat5.0.28 for a javamail servlet program. I am giving the hostname as localhost. After entering the input details in my html file, i get the error- "javax.mail.MessagingException: Connection refused: connect; nested exception is: java.net.ConnectException: Connection refused: connect " .
can anybody help me regarding in solving error.
Thanks.First, you're using a very old version of JavaMail. Please upgrade. Some of the properties you're setting aren't supported in that old version.
Second, you don't need the socket factory properties, get rid of them.
Finally, it looks like you're trying to connect on port 143 using SSL. Port 143 is the non-SSL port. That's probably not going to work. Still, it looks like something is refusing to let you connect at all. If you really can telnet from the same machine your program is running on to the same server machine on port 143, then you probably have some sort of firewall that's preventing your program from connecting. Please post the entire debug output if it still fails after correcting the problems above. (Move the setDebug call to before the getStore call.) -
Javax.mail.MessagingException: Could not connect to SMTP host:
here is a part of my code
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class Mail {
/** Creates a new instance of PostMail */
public Mail() {
public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException
boolean debug = false;
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "smtp."_____".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);
Here is the exception i rec'vd
javax.mail.MessagingException: Could not connect to SMTP host: smtp.google.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
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 Mail.postMail(Mail.java:45)
at ArchMain.<init>(ArchMain.java:30)
at ArchMain$6.run(ArchMain.java:360)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 17 morepackage MailDao;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
import java.text.*;
import java.text.DateFormat.* ;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.activation.*;
import javax.mail.search.*;
import java.util.Vector.*;
import java.sql.*;
public class SendMail {
String SMTP_HOST_NAME = "smtp.techpepstechnology.com";//smtp.genuinepagesonline.com"; //techpepstechnology.com";
String SMTP_AUTH_USER = "[email protected]"; //[email protected]"; //techpeps";
String SMTP_AUTH_PWD = "demo"; //techpeps2007";
public void postMail( String recipients[ ], String subject,
String message , String from,String msgType) throws MessagingException {
boolean debug = false;
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
session.setDebug(debug);
// create a message
MimeMessage msg = new MimeMessage(session);
// MimeMessage mimemessage = new MimeMessage(simplemailuser.getSession());
// 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);
// Setting the Subject and Content Type
msg.setSubject(subject);
if(msgType.equalsIgnoreCase("")) {
//mimemessage.setText(s4);
msg.setContent(message, "text/plain");
else {
MimeBodyPart textBodyPart = new MimeBodyPart();
textBodyPart.setText(message);
MimeBodyPart fileBodyPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(msgType);
fileBodyPart.setDataHandler(new DataHandler(fds));
fileBodyPart.setFileName(fds.getName());
//step:5 create the multipart/container to hold the part
Multipart container = new MimeMultipart();
container.addBodyPart(textBodyPart);
container.addBodyPart(fileBodyPart);
//step:6 add the multipart to the actual message
msg.setContent(container);
try{
Transport transport=session.getTransport("smtp");
transport.connect();
transport.send(msg);
transport.close();
}catch(Exception e) {
e.printStackTrace();
private class SMTPAuthenticator extends javax.mail.Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
public static void main(String arg[]) {
SendMail sm = new SendMail();
String[] s ={"[email protected]"};
try{
sm.postMail(s,"hello","This is testing of mail","[email protected]","");
catch(Exception e)
e.printStackTrace();
//sm.sendMsg("demo", "demo");
System.out.println("Mail Sent");
i also got the follwing error this code work fine in jcreator but i used this in netbeans it throws a exception
plz.....help
javax.mail.MessagingException: Could not connect to SMTP host: smtp.techpepstechnology.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:867)
Mail Sent
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:156)
at javax.mail.Service.connect(Service.java:256)
at javax.mail.Service.connect(Service.java:135)
at javax.mail.Service.connect(Service.java:87)
at com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:93)
at MailDao.SendMail.postMail(SendMail.java:86)
at MailDao.SendMail.main(SendMail.java:110) -
Javax.mail.MessagingException: Not Connected
Hi All,
I am trying to read the message from pop.gmail.com using JavaMail API.I ma using POP3 protocol for it.
But I got the following Exception
javax.mail.MessagingException: Not Connected
at com.sun.mail.pop3.POP3Store.checkConnected(POP3Store.java:279)
at com.sun.mail.pop3.POP3Store.getFolder(POP3Store.java:261)
at MailReceipt.connect(MailReceipt.java:97)
at MailReceipt.mailRecieve(MailReceipt.java:62)
at MailReceipt.main(MailReceipt.java:53)
I got This Error at the line
folder = store.getFolder("INBOX");
in my program.
Please Help me ion this regards.Thanks in Adnavce..
Thanx & Regards
Sandeep VermaWell, I've never used this API but it seems 100% clear what's wrong. And 5 seconds with Google has revealed that there's a method on that class which looks like it will address the issue.
If you can't even read basic error messages, you should seriously question whether you should be programming. -
While trying to run a program to sent sms to mobile(with airtel connection)it shows the Error:
"javax.mail.MessagingException: 505 5.7.3 Client was not Authenticated.
If anyone knows how to resolve this problem please reply.
The Code is as follows:
import java.io.*;
import java.net.InetAddress;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class EmailSMS
String TO;
String FROM;
String SUBJECT,TEXT,MAILHOST,LASTERROR;
public static void main(String [] args) throws Exception
EmailSMS SMS=new EmailSMS();
SMS.setMailHost("kcsl.com");
SMS.setTo("[email protected]");
SMS.setFrom("[email protected]");
SMS.setSubject("");
SMS.setText("Hello World");
boolean ret = SMS.send();
if(ret){
System.out.println("SMS was sent");
else
System.out.println("SMS was not sent"+SMS.getLastError());
public EmailSMS()
TO=null;
FROM=null;
SUBJECT=null;
TEXT=null;
LASTERROR="No methods calls";
public void setTo(String to){TO=to;}
public String getTo(){return TO;}
public void setFrom (String from){FROM=from;}
public String getFrom(){ return FROM;}
public void setSubject(String subject){SUBJECT=subject;}
public String getSubject(){return SUBJECT;}
public void setText(String text){TEXT=text;}
public void setMailHost(String host){MAILHOST=host;}
public String getMailHost(){return MAILHOST;}
public String getLastError(){return LASTERROR;}
public boolean send()
int maxLength;
int msgLength;
//Check to make sure that the parameters are correct
if(TO.indexOf("mobile.att.net")>0)
maxLength=140;
else if(TO.indexOf("messaging.nextel.com")>0)
{maxLength=280;}
else if(TO.indexOf("messaging.sprintpcs.com")>0)
{maxLength=100;}
else maxLength=160;
msgLength=FROM.length()+1+SUBJECT.length()+1+TEXT.length();
if(msgLength>maxLength)
LASTERROR="SMS length too long";
return false;
//set email properties
Properties props=System.getProperties();
if(MAILHOST!=null){props.put("mail.smtp.host",MAILHOST);}
Session session=Session.getDefaultInstance(props,null);
try{
Message msg=new MimeMessage(session);
if(FROM!=null){msg.setFrom(new InternetAddress(FROM));}
else{msg.setFrom();}
msg.setSubject(SUBJECT);
msg.setText(TEXT);
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(TO,false));
msg.setSentDate(new Date());
Transport.send(msg);
LASTERROR="Success";
return true;
catch(MessagingException max ){LASTERROR=max.getMessage();
return false;}
thankuHi,
it seems to me that you must authenticate with your smtp host. In order to do so, try following:
While trying to run a program to sent sms to
mobile(with airtel connection)it shows the Error:
"javax.mail.MessagingException: 505 5.7.3 Client was
not Authenticated.
If anyone knows how to resolve this problem please
reply.
The Code is as follows:
import java.io.*;
import java.net.InetAddress;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class EmailSMS
String TO;
String FROM;
String SUBJECT,TEXT,MAILHOST,LASTERROR;
public static void main(String [] args) throws
Exception
EmailSMS SMS=new EmailSMS();
SMS.setMailHost("kcsl.com");
SMS.setTo("[email protected]");
SMS.setFrom("[email protected]");
SMS.setSubject("");
SMS.setText("Hello World");
boolean ret = SMS.send();
if(ret){
System.out.println("SMS was sent");
else
System.out.println("SMS was not
t sent"+SMS.getLastError());
public EmailSMS()
TO=null;
FROM=null;
SUBJECT=null;
TEXT=null;
LASTERROR="No methods calls";
public void setTo(String to){TO=to;}
public String getTo(){return TO;}
public void setFrom (String from){FROM=from;}
public String getFrom(){ return FROM;}
public void setSubject(String
subject){SUBJECT=subject;}
public String getSubject(){return SUBJECT;}
public void setText(String text){TEXT=text;}
public void setMailHost(String host){MAILHOST=host;}
public String getMailHost(){return MAILHOST;}
public String getLastError(){return LASTERROR;}
public boolean send()
int maxLength;
int msgLength;
//Check to make sure that the parameters are correct
if(TO.indexOf("mobile.att.net")>0)
maxLength=140;
else if(TO.indexOf("messaging.nextel.com")>0)
{maxLength=280;}
else if(TO.indexOf("messaging.sprintpcs.com")>0)
{maxLength=100;}
else maxLength=160;
msgLength=FROM.length()+1+SUBJECT.length()+1+TEXT.leng
h();
if(msgLength>maxLength)
LASTERROR="SMS length too long";
return false;
//set email properties
Properties props=System.getProperties();
if(MAILHOST!=null){props.put("mail.smtp.host",MAILHOST
Session
session=Session.getDefaultInstance(props,null);
try{ // Get a Transport object to send e-mail
Transport bus = session.getTransport("smtp");
// Connect only once here
// Transport.send() disconnects after each send
bus.connect(host, username, password);
Message msg=new MimeMessage(session);
if(FROM!=null){msg.setFrom(new
w InternetAddress(FROM));}
else{msg.setFrom();}
msg.setSubject(SUBJECT);
msg.setText(TEXT);
msg.setRecipients(Message.RecipientType.TO,InternetAd
ress.parse(TO,false));
msg.setSentDate(new Date());// Send message
bus.send(msg);
bus.close();
LASTERROR="Success";
return true;
catch(MessagingException max
){LASTERROR=max.getMessage();
return false;}
thankuGood luck -
SHA1 digest error for javax/mail/MessagingException
java.lang.SecurityException: SHA1 digest error for javax/mail/MessagingException.class
at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:194)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:201)
at java.util.jar.JarVerifier.update(JarVerifier.java:188)
at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:411)
at sun.misc.Resource.getBytes(Resource.java:97)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:256)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
What could be the problem for this error Exception ???
Thanks and Regards.Hi!
Do you use some plugins with eclipse IDE, like Tomcat by example or other plugins ... ?
If yes, update mail.jar and activation.jar inside Tomcat or in your lib project Eclipse...
You have a conflict with the class loader that check for security for class javax/mail/MessagingException
See you Manifest.mf inside mail.jar :
(old version here...)
Manifest-Version: 1.0
Implementation-Version: 1.4
Specification-Title: JavaMail(TM) API Design Specification
Specification-Version: 1.3
Implementation-Title: javax.mail
Extension-Name: javax.mail
Created-By: 1.5.0 (Sun Microsystems Inc.)
Implementation-Vendor-Id: com.sun
Implementation-Vendor: Sun Microsystems, Inc.
Specification-Vendor: Sun Microsystems, Inc.
SCCS-ID: @(#)javamail.mf 1.6 05/12/09
Name: javax/mail/search/SearchTerm.class
SHA1-Digest: SwGnDhIUmpZhfhq/FKkCQ9nD7ZE=
Name: javax/mail/SendFailedException.class
SHA1-Digest: XdCEygaIZQB9YrH2WIr4nPRYYk0=
Name: javax/mail/MessagingException.class
SHA1-Digest: lfjX30OQ88v/n9G9fTJGqjFmPd0=
regards, -
I am getting this exception , while my application is trying to send mails. The complete stack trace is below
com.bp.ebus.downstream.util.ErrorLevelException: javax.mail.MessagingException: 452 4.4.5 Insufficient disk space; try again
later
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:879)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:599)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:319)
at com.bp.ebus.interfaces.SmtpClient.sendMessage(SmtpClient.java:252)
at com.bp.ebus.interfaces.SmtpClient.send(SmtpClient.java:191)
at com.bp.ebus.downstream.ejb.ServicesSessionBean.sendNewEmails(ServicesSessionBean.java:105)
at com.bp.ebus.downstream.ejb.ServicesSessionBean_f7hinc_EOImpl.sendNewEmails(ServicesSessionBean_f7hinc_EOImpl.java:
166)
at com.bp.ebus.downstream.ejb.ServicesSessionBean_f7hinc_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:305)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:274)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:85)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy4.sendNewEmails(Unknown Source)
at com.bp.ebus.lighthouse.jobs.SendEmail.run(SendEmail.java:70)
at java.util.TimerThread.mainLoop(Timer.java:435)
at java.util.TimerThread.run(Timer.java:385)
My OS is solaris and Application server is weblogic.The message is coming from your mail server.
Looks like your server is out of disk space.
Maybe you are looking for
-
Photodownloader in Photoshop CS5 freezes when choosing a directory
This just recently happened in the last week. When I insert my CF card in my card reader and Adobe Bridge CS5 and photo downloader opens up, it hangs when I try to change the location where to download the files to. So in photodownloader, I select th
-
Java.lang.NullPointerException in Integration Directory
Hi, when i am trying to create Configuaration Scenario in ID it is giving error as " java.lang.NullPointerException" Could any one help on this.. Thanks in Advance. Regards, Vijay
-
WHEN I OPEN IT THERE IS NOTHING EMPTY BOXES
it started a few weeks ago. foxfire open's to no words just empty boxes
-
Brand new piece problem PLEASE Help Me!!!
I purchased 7210 supernova & 5130 music express & within an month supernova earpiece was not working & mike too & about 5130 music express one one sim card works I tried to inser another sim card it doesnot works..and when i asked the dealer about th
-
Foreign currecy valuation issue
Hello, F.05 was executed with valuation date 31.12.2010 first on 05/01/2011. The batch session was executed & it gave correct postings. The user again executed the program F.05 on 07/01/2011 & the batch session was executed again.So, I have the posti