#1 2020-12-05 10:03:42

reportserveruser
Member
Registered: 2020-11-02

Connection refused error when I try to configure the mail

Hi,

I want to send the reports to my clients via automated mails. The mail.cf configuration file is as follows -


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <smtp>
      <host>smtp.agsindia.com</host>
      <port>465</port>
      <username>xxxx@agsindia.com</username>
      <password>xxxx</password>
      <ssl>false</ssl>
      <tls>
         <enable>true</enable>
         <require>false</require>
      </tls>
   </smtp>
   <mail>
      <sender>xxxx@agsindia.com</sender>
      <forceSender>false</forceSender>
      <encryptionPolicy>allow_mixed</encryptionPolicy>
   </mail>
</configuration>


I'm getting the below exception -


java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.agsindia.com, port: 465;
  nested exception is:
    java.net.ConnectException: Connection refused: connect
    at net.datenwerke.rs.scheduler.service.scheduler.mail.MailReportAction$1.handleException(MailReportAction.java:149)
    at net.datenwerke.rs.core.service.mail.MailServiceImpl.sendMailSync(MailServiceImpl.java:247)
    at net.datenwerke.rs.scheduler.service.scheduler.mail.MailReportAction.doExecute(MailReportAction.java:140)
    at net.datenwerke.scheduler.service.scheduler.entities.AbstractAction.execute(AbstractAction.java:59)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeAction(SchedulerTask.java:614)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeActions(SchedulerTask.java:502)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.safeCall(SchedulerTask.java:211)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.call(SchedulerTask.java:103)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.call(SchedulerTask.java:1)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.agsindia.com, port: 465;
  nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
    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 net.datenwerke.rs.core.service.mail.MailServiceImpl.sendMailSync(MailServiceImpl.java:237)
    ... 11 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.base/java.net.PlainSocketImpl.connect0(Native Method)
    at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
    at java.base/java.net.Socket.connect(Socket.java:609)
    at java.base/java.net.Socket.connect(Socket.java:558)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)
    ... 18 more


Could you please help me fix this error?

Offline

#2 2020-12-07 07:43:54

Tobias F
Administrator
Registered: 2020-02-07

Re: Connection refused error when I try to configure the mail

Hi,

your configuration (xml) seems correct, but your email server blocks the connection. Our configuration is almost the same (ssl = false, tls =true) but over a different port 587.

Try to change it and keep me updated.

Regards,
Tobias

Offline

#3 2020-12-09 07:24:41

reportserveruser
Member
Registered: 2020-11-02

Re: Connection refused error when I try to configure the mail

Hi Admin,

Sorry, I am responding a little late. Had to get the port opened on the server from the IT team to be able to test it out.

I did the following telnet - telnet smtp.agsindia.com 587 and I got a proper response. I've modified the configuration file accordingly -

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <smtp>
      <host>smtp.agsindia.com</host>
      <port>587</port>
      <username>xxxx@agsindia.com</username>
      <password>xxxx</password>
      <ssl>false</ssl>
      <tls>
         <enable>true</enable>
         <require>false</require>
      </tls>
   </smtp>
   <mail>
      <sender>xxxx@agsindia.com</sender>
      <forceSender>false</forceSender>
      <encryptionPolicy>allow_mixed</encryptionPolicy>
   </mail>
</configuration>

And now I get the following exception -

09-Dec-2020 12:44:01.162 WARNING [pool-DwAsyncService-2-thread-1] net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeActions action execution failed
    java.lang.RuntimeException: com.sun.mail.smtp.SMTPSendFailedException: 501 5.7.1 <sentoaddress.mumbai@gmail.com>... Permission denied
;
  nested exception is:
    com.sun.mail.smtp.SMTPSenderFailedException: 501 5.7.1 <sentoaddress@gmail.com>... Permission denied

        at net.datenwerke.rs.scheduler.service.scheduler.mail.MailReportAction$1.handleException(MailReportAction.java:149)
        at net.datenwerke.rs.core.service.mail.MailServiceImpl.sendMailSync(MailServiceImpl.java:247)
        at net.datenwerke.rs.scheduler.service.scheduler.mail.MailReportAction.doExecute(MailReportAction.java:140)
        at net.datenwerke.scheduler.service.scheduler.entities.AbstractAction.execute(AbstractAction.java:59)
        at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeAction(SchedulerTask.java:614)
        at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeActions(SchedulerTask.java:502)
        at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.safeCall(SchedulerTask.java:211)
        at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.call(SchedulerTask.java:103)
        at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.call(SchedulerTask.java:1)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
    Caused by: com.sun.mail.smtp.SMTPSendFailedException: 501 5.7.1 <sentoaddress@gmail.com>... Permission denied
;
  nested exception is:
    com.sun.mail.smtp.SMTPSenderFailedException: 501 5.7.1 <sentoaddress@gmail.com>... Permission denied

        at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114)
        at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1618)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1119)
        at javax.mail.Transport.send0(Transport.java:195)
        at javax.mail.Transport.send(Transport.java:124)
        at net.datenwerke.rs.core.service.mail.MailServiceImpl.sendMailSync(MailServiceImpl.java:237)
        ... 11 more
    Caused by: com.sun.mail.smtp.SMTPSenderFailedException: 501 5.7.1 <sentoaddress@gmail.com>... Permission denied

        at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1625)
        ... 15 more

Could you please help me with this?

Last edited by reportserveruser (2020-12-09 07:27:56)

Offline

#4 2020-12-09 12:24:16

Tobias F
Administrator
Registered: 2020-02-07

Re: Connection refused error when I try to configure the mail

Hi,

at this point, that is obviously not a Reportserver related issue.

It's the right way to test your email server via telnet, but also try to send a mail via telnet. Thusly you will see, that the exception 'java.lang.RuntimeException: com.sun.mail.smtp.SMTPSendFailedException: 501 5.7.1' shows that your email server is the issue.

Maybe your username or password is the problem: https://support.google.com/a/answer/3726730?hl=en
535, "5.7.1", Username and Password not accepted. For more information, see Can't sign in to your Google Account.

I looked up the exception and found this https://www.stellarinfo.com/article/exc … -relay.php

Regards,
Tobias

Offline

Board footer

Powered by FluxBB