Меню

Exception reading response ошибка

Here is a little code to send email from java.

public static void sendMail(){
    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.host", "mail.domain.tld");
    props.put("mail.smtp.debug", "true");
            Session session = Session.getInstance(props,
      new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication("sender@domain.tdl", "pwd");
        }
      });
    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress("sender@domain.tdl"));
        message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse("receiver@yahoo.fr"));
        message.setSubject("Testing Subject");
        message.setContent("This is a test <b>HOWTO<b>", "text/html; charset=ISO-8859-1");
        Transport.send(message);
        System.out.println("Done");
    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}

But running it I have this error

Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Exception reading response;
  nested exception is:
    java.net.SocketException: Software caused connection abort: recv failed
    at Test.main(Test.java:112)
Caused by: javax.mail.MessagingException: Exception reading response;
  nested exception is:
    java.net.SocketException: Software caused connection abort: recv failed
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2445)
    at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2307)
    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2340)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1808)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1285)
    at javax.mail.Transport.send0(Transport.java:255)
    at javax.mail.Transport.send(Transport.java:124)
    at Test.main(Test.java:107)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:126)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:104)
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2425)
    ... 7 more

I don’t understand the reason of the error because this code worked for me in the past.
Here is the jars I’m using:

  • dsn-1.6.0
  • gimap-1.6.0
  • imap-1.6.0
  • javax.mail-1.6.0
  • javax.mail-api-1.6.0
  • logging-mailhandler-1.6.0
  • mailapi-1.6.0
  • pop3-1.6.0
  • smtp-1.6.0

After modification asked by @Bill, here is the new error I have

Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: mail.hereka.org, port: 25;
  nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at Test.main(Test.java:134)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: mail.hereka.org, port: 25;
  nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2196)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726)
    at javax.mail.Service.connect(Service.java:366)
    at javax.mail.Service.connect(Service.java:246)
    at javax.mail.Service.connect(Service.java:267)
    at javax.mail.Transport.send0(Transport.java:252)
    at javax.mail.Transport.send(Transport.java:174)
    at Test.main(Test.java:130)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:671)
    at sun.security.ssl.InputRecord.read(InputRecord.java:504)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:619)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:393)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
    ... 7 more

But if I remove the ssl property this is the new error

Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Exception reading response;
  nested exception is:
    java.net.SocketException: Software caused connection abort: recv failed
    at Test.main(Test.java:134)
Caused by: javax.mail.MessagingException: Exception reading response;
  nested exception is:
    java.net.SocketException: Software caused connection abort: recv failed
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2445)
    at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2307)
    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2340)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1808)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1285)
    at javax.mail.Transport.send0(Transport.java:255)
    at javax.mail.Transport.send(Transport.java:174)
    at Test.main(Test.java:130)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:126)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:104)
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2425)
    ... 7 more

Thanks

использую данные с mail.ru

IMAP, SMTP и POP3-серверы Mail.Ru
Для настройки почтовой программы вам потребуется следующая информация:

Электронный адрес Полное имя почтового ящика, включая логин, @ и домен
Сервер входящей почты (IMAP- и POP3-сервера) IMAP-сервер — imap.mail.ru
POP3-сервер — pop.mail.ru
Сервер исходящей почты (SMTP-сервер) smtp.mail.ru
Имя пользователя
Полное имя почтового ящика, включая логин, @ и домен

Пароль Пароль, который вы используете для входа в почтовый ящик
Порт IMAP — 993 (протокол шифрования SSL/TLS)
POP3 — 995 (протокол шифрования SSL/TLS)
SMTP — 465 (протокол шифрования SSL/TLS)
Аутентификация Обычный пароль (без шифрования)
В настройках почтовой программы необходимо указать, что сервер исходящей почты (или сервер SMTP) требует авторизации.

Добавлено через 30 минут
Странно:

DEBUG: JavaMail version 1.4.7
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Pro vider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport ,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provide r[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Ora cle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport ,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Ora cle]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Ora cle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host «smtp.mail.ru», port 465, isSSL false
DEBUG SMTP: exception reading response, THROW:
Exception : javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketTimeoutException: Read timed out
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputS tream.java:116)
at java.net.SocketInputStream.read(SocketInputStream. java:171)
at java.net.SocketInputStream.read(SocketInputStream. java:141)
at com.sun.mail.util.TraceInputStream.read(TraceInput Stream.java:124)
at java.io.BufferedInputStream.fill(BufferedInputStre am.java:246)
at java.io.BufferedInputStream.read(BufferedInputStre am.java:265)
at com.sun.mail.util.LineInputStream.readLine(LineInp utStream.java:89)
at com.sun.mail.smtp.SMTPTransport.readServerResponse (SMTPTransport.java:2182)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTra nsport.java:1939)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SM TPTransport.java:654)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at by.htp.library.action.util.EmailSender.sendingEmai l(EmailSender.java:56)
at by.htp.library.dao.impl.BookDaoMySql.anserRenting( BookDaoMySql.java:739)
at by.htp.library.action.console.renting.AnswerRentin g.doHttpReqRes(AnswerRenting.java:31)
at by.htp.library.controller.SimpleServletController. doGet(SimpleServletController.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:729)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilt er(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve. invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProce ssor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProce ssor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$Wrapping Runnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)



0



Hi,

I am using the below code to connect to SMTP server which is SSL enabled and send a test email.

———————————————————————————————————————————————————

import java.util.Date;

import java.util.Properties;

import javax.mail.Address;

import javax.mail.Authenticator;

import javax.mail.Message;

import javax.mail.PasswordAuthentication;

import javax.mail.Session;

import javax.mail.Transport;

import javax.mail.internet.InternetAddress;

import javax.mail.internet.MimeMessage;

/*

  This class is a Standalone utility to check connection with SMTP server.

*/

public class SMTPTLSTest

{  

  public static void main(String args[] )   

  {

     Session session;    

     String smtpServer = args[0];

     String port = args[1];

     String userName = args[2];

     String password = args[3];

     String fromAddr = args[4];

     String toAddr = args[5];

     String truststore = args[6];

     Address[] addresses = null;

     MimeMessage mimeMessage = null;

     Properties smtpProperties = new Properties();

     smtpProperties.put(«mail.transport.protocol», «smtp»);

     smtpProperties.put(«mail.smtp.host», smtpServer);

     smtpProperties.put(«mail.smtp.port», port);

     smtpProperties.put(«mail.smtp.auth», «true»);   

     smtpProperties.put(«mail.smtp.user», userName);

     smtpProperties.put(«mail.smtp.password», password); 

     smtpProperties.put(«mail.smtp.connectiontimeout», 60000); 

     smtpProperties.put(«mail.smtp.timeout», 60000);

     System.getProperties().setProperty(«java.security.debug», «ssl»);

     System.getProperties().setProperty(«javax.net.debug», «all»);

     System.setProperty(«javax.net.ssl.trustStore», truststore);

     System.getProperties().setProperty(«java.security.debug»,»all»);

     smtpProperties.put(«mail.smtp.socketFactory.class», «javax.net.ssl.SSLSocketFactory»);

     smtpProperties.put(«mail.smtp.socketFactory.fallback», «false»);

     smtpProperties.put(«mail.smtp.socketFactory.port», port);

     System.out.println(«SMTPTLSTest. The given smtp host name, port, username and password values are:» + smtpServer

                       + «,» + port + «,» + userName + «,» + password );

     System.out.println(«SMTPTLSTest. The given From address and Recipient email addresses are:» + fromAddr

                       + «,» + toAddr);

     try

     {

       Authenticator authenticator = new TestAuthenticator(userName, password);

       session = Session.getInstance(smtpProperties, authenticator);

       mimeMessage = new MimeMessage(session);

       System.out.println(«SMTPTLSTest. Obtained the session object.»);

       Address[] from = InternetAddress.parse(fromAddr, false);

       mimeMessage.addFrom(from);

       mimeMessage.setRecipients(Message.RecipientType.TO, toAddr);

       mimeMessage.setSubject(«Test mail from outlook365»);

       mimeMessage.setText(«This is just a test mail to test SMTP connectionn»);

       mimeMessage.setSentDate(new Date());

       addresses = InternetAddress.parse(toAddr, false);

       mimeMessage.setFrom(from[0]);

       System.out.println(«SMTPTLSTest. Sending test email to » + toAddr + » …»);

       Transport.send(mimeMessage, addresses);

       System.out.println(«SMTPTLSTest. Message has been sent»);

    }

    catch(Exception ex)

    {

       System.out.println(«SMTPTLSTest. Exception occured while sending message:»+ex);

       ex.printStackTrace();

    }

  } // end of main ()

} // end of class

class TestAuthenticator extends Authenticator

{

  String username;

  String password;

  TestAuthenticator(String name, String passwd)

  {

     username = name;

     password = passwd;

  }

  public PasswordAuthentication getPasswordAuthentication()

  {

     return new PasswordAuthentication(username, password);      

  }   

}

———————————————————————————————————————————————

It was throwing the below error using java mail API 1.5.4 version..

javax.mail.MessagingException: Exception reading response;

  nested exception is:

        java.net.SocketException: Connection reset

        at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2305)

        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2032)

        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)

        at javax.mail.Service.connect(Service.java:386)

        at javax.mail.Service.connect(Service.java:245)

        at javax.mail.Service.connect(Service.java:194)

        at javax.mail.Transport.send0(Transport.java:253)

        at javax.mail.Transport.send(Transport.java:146)

        at SMTPTLSTest.main(SMTPTLSTest.java:96)

Caused by: java.net.SocketException: Connection reset

        at java.net.SocketInputStream.read(SocketInputStream.java:196)

        at java.net.SocketInputStream.read(SocketInputStream.java:122)

        at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:124)

        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)

        at java.io.BufferedInputStream.read(BufferedInputStream.java:254)

        at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:92)

        at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2285)

        … 8 more

The same code is working fine with java mail API 1.4.3 version.

Is there any changes with the java mail API version 1.5.4?

What is the issue with this code? Please provide pointers to resolve this issue.

Платные услуги для вашего проекта

  • Консалтинг и техническая поддержка

    Запросы в рамках коммерческой поддержки имеют гарантированное время ответа

  • Разработка на заказ

    Предоставляем разработку полностью нашими рабочими ресурсами или участвуем в создании вашего проекта

  • Обучение

    Для быстрого и всестороннего освоения особенностей платформы, чтобы повысить продуктивность вашей команды

Haulmont

мы разрабатываем современные корпоративные решения

  • Эксперты в области разработки корпоративного ПО

  • Создатели CUBA Platform

  • Компания основана в 2008

  • 300+

    разработчиков

  • 400+

    проектов

  • Клиенты в

    60+

    странах

I never had a problem with older versions of Yawcam, but the current version simply will not connect with smtp.

Service: Gmail
Server: smtp.gmail.com
User: My email, with @gmail.com per Gmail Support page
Pass: My password
Port: 465
Authentication: Yes

Compatibility mode for Windows 7 (I’m on x64) on or off, same problem. Ditto run as admin or not. I usually send from the same address I’m mailing to without a problem (sending to myself). Tried sending from another account. Same problem.

A windows firewall exception has been made, I’ve tried forwarding ports 25 (both), 8888 (tcp), and 8081 (both), I’ve never had to make an outbound smtp rule in Windows Firewall before… I get this exception every email event.

As I was building this new PC, I installed Yawcam on my old one. That PC has since been given to a friend, but this was only a couple of days ago and the old version on that PC worked. Since I don’t have that PC anymore, and my friend has since formatted the HDD, I’m stuck with this new version that simply does not work. Is there any workaround or fix to this? Barring that, is it possible to download older versions? I have an ex who is prone to thievery, and I’m stuck at home until I can cover my place to make sure if either she or her friends break in then they’re caught. Today I had to skip out on plans because I couldn’t get this working.

Found this: http://www.yawcam.com/dist/

I’ll update when/if I find a version that works or if I don’t, so that my idea about the version is either confirmed or falsified. Got down to 3.8, same problem, and that’s the version I had before. So it’s not a change in Yawcam.

Using tls://smtp.gmail.com, the exception error is not given but the email still does not get sent.

All caps in to and from fields makes no difference. Using hotmail to send gives no exception message, but still does not send. I’ve now exhausted every solution posted anywhere, with no change. Time to uninstall and try other programs. It’s a shame because I’ve been using Yawcam for years and would actually purchase it in its previous state. I can’t even confirm whether this issue is caused by Yawcam, Windows, Java, or Gmail.

1, Java mail mail can be sent successfully, but will throw such an exception

org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: Exception reading response (java.net.SocketTimeoutException: Read timed out)
    at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:448) ~[spring-context-support-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:346) ~[spring-context-support-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:341) ~[spring-context-support-4.1.0.RELEASE.jar:4.1.0.RELEASE]

 

2. The Java code structure is as follows:

					String SSL_FACTORY="javax.net.ssl.SSLSocketFactory";
					Properties prop = new Properties();
/*					prop.put("mail.smtp.auth", "0".equals(smtp
							.get("mail_needauth")) ? "true" : "false");*/
					prop.put("mail.smtp.auth", "true");
					// Set this parameter to true to let the server authenticate and verify that the username and password are correct.
					prop.put("mail.smtp.timeout", smtp.get("SMTP_TIME_OUT"));
					prop.put("mail.smtp.host", host);
					prop.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
					prop.setProperty("mail.smtp.socketFactory.fallback", String.valueOf(port));
					prop.setProperty("mail.smtp.starttls.enable", "true");
					prop.setProperty("mail.smtp.socketFactory.port", String.valueOf(port));
					prop.setProperty("mail.smtp.auth", "true");
					 // Add verification
					EmailAutherticator auth = new EmailAutherticator(name, pwd);

					Session session = Session.getDefaultInstance(prop, auth);
					senderImpl.setSession(session);

3. Solution:

Set the timeout to solve…

Problem

When sending a test email via an STARTTLS  connection mail won’t be sent and the following error message is displayed:

com.atlassian.mail.MailException: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketTimeoutException: Read timed out

The following appears in the atlassian-confluence.log

An error has occurred with sending the test email:
com.atlassian.mail.MailException: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketTimeoutException: Read timed out
at com.atlassian.confluence.jmx.JmxSMTPMailServer.doSendWithMessageIdSupport(JmxSMTPMailServer.java:143)
at com.atlassian.confluence.jmx.JmxSMTPMailServer.send(JmxSMTPMailServer.java:88)
at com.atlassian.confluence.admin.actions.mail.SendTestEmailAction.execute(SendTestEmailAction.java:60)

Diagnosis

Environment

If you unsure you had STARTTLS mail server or SSL mail server, you can you below’s tool to identify it 

http://www.checktls.com/perl/TestReceiver.pl

Resolution

Since STARTTLS upgrades the connection to TLS after it has been established, the standard way of retrieving SSL certificates will not work.

Additional argument «-starttls smtp» is required in the openssl call.

openssl s_client -debug -connect mail.mycompany.com:587 -starttls smtp < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt
jre/bin/keytool -import -alias tomcat -keystore jre/lib/security/cacerts -file public.crt

(info) Standard certificate store password is «changeit».

Repeating this for all required certificates

  • Remove From My Forums
  • Question

  • Hello Folks, 

    Having a very strange issue , We have a Cognos Application server (IBM Cognos) through which user used to send an email in bulk with excel attachements so what is happening like there are 10 users so mail is reaching to 8 only not to 2 and then again when application
    is sending an email then again some other are getting dropped its random not the same everytime. We check the logs / message trace but did not find any issues. and through application they are getting below errors . Its not only external users internal as
    well. Any pointers and another logs do we need to check..

    CNC-SDS-0335 Error returned from SMTP Server. The error message was: [Exception reading response]. The message could not be sent.

    CNC-SDS-0335 Error returned from SMTP Server. The error message was: [Connection reset]. The message could not be sent.

    CNC-SDS-0335 Error returned from SMTP Server. The error message was: [[EOF]]. The message could not be sent.
    CNC-SDS-0410 The email message was not sent . Approximate message size . The mail server returned this error [[EOF]].

    IBM is straight forward is saying that Error is related to SMTP so you need to check SMTP server only


Error: javax.mail.MessagingException: Exception reading response;


posted 13 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Hi,

While executing a program for sending the mails, i got this exception : Error: javax.mail.MessagingException: Exception reading response;

nested exception is:

java.net.SocketException: Connection reset.

This means that my connection has established with server(SMTP) ?

In General , what i need to do to solve this problem. When it occured?

Please help me.

Amit S. Pawar

SCJP,SCWCD,OCA


posted 13 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Most probably the socket is not opened with specified port, or the particular service is not running on target machine, or a firewall is blocking access on the specified owing to which the socket connection cannot be established. Can you post the code or at least the stack trace ?

Thanks and Regards

Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]


posted 13 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

It appears the connection was reset / aborted. Perhaps some one is closing the connection before any work can get done

Amit Suresh Pawar

Ranch Hand

Posts: 30


posted 13 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Thanks a lot……..

Amit S. Pawar

SCJP,SCWCD,OCA

wood burning stoves

Я пытаюсь отправить email с помощью следующего кода:

  try {
        String mailFrom = "[email protected]";
        String pass = "pass";
        String mailTo = "[email protected]";

        java.util.Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.mail.ru");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "587"); 
        props.put("mail.smtp.starttls.enable", "true");

        props.put("mail.smtp.connectiontimeout", "60000"); // 60 seconds
        props.put("mail.smtp.timeout", "60000");

        Session session = Session.getInstance(props, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return (new PasswordAuthentication(mailFrom, pass));
            }
        });
        Message msg = new MimeMessage(session);
        InternetAddress addressFrom = new InternetAddress(mailFrom);
        msg.setFrom(addressFrom);
        InternetAddress addressTo = new InternetAddress(mailTo);
        msg.setRecipient(Message.RecipientType.TO, addressTo);
        msg.setSubject("testemail");
        Transport.send(msg);
   } catch (Throwable e) {
        System.err.println("Exception : " + e.toString());
   } 

но получаю ошибку:

Exception : javax.mail.MessagingException: Could not convert socket to
TLS;
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

При этом я добавила ssl-сертификат mail.ru в хранилище сертификатов JVM, и он был успешно добавлен.

Если же я добавляю в сессию следующее свойство:

props.put("mail.smtp.ssl.trust", "*");

то по прошествии минуты (по истечении установленного таймаута) получаю другую ошибку:

Exception : javax.mail.MessagingException: Exception reading response;
nested exception is: java.net.SocketTimeoutException: Read timed out

Как исправить это и всё-таки отправить email?

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Exception processing message 0xc00000a2 ошибка защиты от записи
  • Exception processing message 0xc0000006 unexpected parameters ошибка