grails : Could not connect to SMTP host: *********, port: 25 - java

Can anyone help me with this, I was unable to send email from my app and experiencing below errors.
Logs:
Could not connect to SMTP host: ****.******.** port: 25;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.webbfontaine.ci, port: 25;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?; message exception details (1) are:
Failed message 1:
javax.mail.MessagingException:
Could not connect to SMTP host: ****.******.**, port: 25;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1986)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:656)
at javax.mail.Service.connect(Service.java:345)
at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:486)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:406)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)
Here is my grails config:
grails{
mail {
disabled = false
host = "*****.****.**"
port = 25
username = "account"
password=""
props = ["mail.smtp.auth":"false",
"mail.smtp.socketFactory.port":"25"]
}
}
Build COnfig:
compile ":mail:1.0.7"
Hoping for your generous help.
Thanks

The error message also points to an SSL connection. Seems like you are trying to connect to an SSL port using standard SMTP TCP. Here is a Stack Over flow that has a similar error message.
unrecognized ssl message plaintext connection exception

Make sure you use correct SSL port number. By default SSL/TLS encrypted SMTP uses port 465.

Related

Getting javax.net.ssl.SSLHandshakeException: No appropriate protocol exception while sending mail through smtp

I am trying to send the mail from my spring boot application. The following are the smtp configurations I have added in application.yml
spring:
mail:
host: smtp.gmail.com
port: 587
username: ${username}
password: ${app-password}
properties:
mail:
transport:
protocol: smtp
smtp:
auth: true
starttls:
enable: true
But when I am trying to send the mail, I am getting the following exception
Mail server connection failed; nested exception is
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate).
Failed messages: javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)"
Please help me with this. I have searched many blogs, my configurations seems to be fine. Let me know If I need to change or add something.
Thanks in advance!
This looks tls algorithm is part of your disabledAlgorithms list in jdk which is running in your system.
While link shared by Marc Stroebel might help you but if you want to set this programatically as well, then you can use below in your spring startup :
#SpringBootApplication
public class App {
public static void main(String[] args) {
java.security.Security.setProperty("jdk.tls.disabledAlgorithms", "");
..
..
}
}
This will allow all algorithms while app execution.

Send mail with own host in google cloud server

I have my own smtp host. like, mail.xxx.com. and my application is host on Google Cloud Server. now when i send mail then it's give this type of error.
DEBUG SMTP:
useEhlo true, useAuth trueDEBUG SMTP: trying to connect to host "mail.xxx.com", port 587, isSSL falseorg.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException:
Could not connect to SMTP host: mail.xxx.com, port: 587;
nested exception is: java.net.ConnectException: Connection refused (Connection refused).
Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: mail.xxx.com, port: 587;
Mail Configuration Properties ::
mail.config.smtp.host=mail.xxx.com
mail.config.smtp.port=587
mail.config.smtp.username=noreply#xxx.com
mail.config.smtp.password=xxx
mail.config.smtp.auth=true
mail.config.smtp.starttls.enable=true
If anyone face this type of error and got the solution then please guide me.

javax.mail.MessagingException: Could not connect to SMTP host: smtp.live.com, port: 587

I've implemented a code that sends e-mails using Outlook server (worked fine locally).
What's the cause of the following exception on my production environment and how do I resolve it?
javax.mail.MessagingException: Could not connect to SMTP host: smtp.live.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out

java mail api-not connect to smtp host

I am sending mail from our application. The properties used as follows,
"mail.smtp.auth", "true"
"mail.smtp.host", smtp.bizmail.yahoo.com
"mail.smtp.port", 587
We have two linux servers, my problem is that from one server it send mail, but from other server it not send mail. It throws exception as follows
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.bizmail.yahoo.com, port: 587;
nested exception is:
java.net.ConnectException: Connection timed out
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)

Java Mail Error : java.net.ConnectException: Connection refused: connect

I am stuck with the mail sending with Java Mail API.
I am not able to connect SMTP server with any kind of properties... I have tried with different combination.
I am connecting SMTP Remote server (Server is not at localhost, its in LAN), with port 25 but it gives me the port error to 465, I dont know why ?
javax.mail.MessagingException: Could not connect to SMTP host: *RemoteIP*, port: 465; nested exception is: java.net.ConnectException: Connection refused: connect
If anyone can help.
Thankx in advance.
Maybe your mail server is actually using SMTPS on port 465 (although it's not the recommended port). If that is the case you can see here an example of using JavaMail with SMTPS. Note the property mail.smtps.host; you also have the mail.smtps.port property to specify 465.

Categories