Android SMTP mail sender with SSL ignore - java

Iam trying to use the JavaMail examples found online to send emails from my Android application using a custom SMTP server. The SMTP server does not have a valid SSL certificate, instead it uses a self signed one so when I try to connect I get an SSL Handshake exception.
I tried to use the :
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl.checkserveridentity", "false");
props.put("mail.smtp.ssl.trust", "*");
properties but then I get the error:
E/SendMail(17874): Could not connect to SMTP host: {MY_SMTP_HOST}, port: {MY_SMTP_PORT}, response: -1
Any suggestions? Is there any other library that supports sending emails through SMTP?

Related

How to send ZOHO SMTP server mail in java?

I have been using ZOHO SMTP server for sending out email. but it was working in localhost server ,when deploying my code into AWS server it not going to be working,it is giving Exception like below..
javax.mail.MessagingException: Could not connect to SMTP host: smtp.zoho.com, port: 465;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
My java code is :-
Properties prop = new Properties();
prop.put("mail.smtp.host", "smtp.zoho.com");
prop.put("mail.smtp.port", 465);
prop.setProperty("mail.smtp.user", username);
prop.setProperty("mail.smtp.password", password);
prop.setProperty("mail.smtp.auth", "true");
// prop.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
prop.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
prop.setProperty("mail.smtp.socketFactory.fallback", "false");
prop.setProperty("mail.smtp.socketFactory.port", "465");
// prop.put("mail.smtp.starttls.enable", "true");
// prop.setProperty("mail.smtps.tls.enable", "true");
The above code is working in my localhost server (Tomcat).
can any one please help to solve out this.
465 is SSL port. It looks like SSL certificate from ZOHO is missing in AWS. Download/obtain certificate from Zoho and import it on AWS's Keystore. It should solve the problem.
Check https://help.zoho.com/portal/community/topic/ssl-security-certificate-updated-pop-imap-and-smtp-servers from similar problem and possible solutions.

Java.net.SocketException: Permission denied: connect in Pentaho Data Integration

I try to send an e-mail with the help of Pentaho, but something blocks my shipment. Can anyone help me? I get in the log:
2019/04/02 14:35:29 - Mail - ERROR (version 8.1.0.0-365, build 8.1.0.0-365 from 2018-04-30 09.42.24 by buildguy) : Problem while sending message: javax.mail.MessagingException: Could not connect to SMTP host: smtp..., port: 25;
nested exception is:
java.net.SocketException: Permission denied: connect
I have marked:
Use authentication? true
Use secure authentication? true
Secure connection type: TLS
There's a problem with connecting to the mail server. You need to either double check your connection info, or you need to configure your mail server to work with Pentaho. For example, if you're trying to use Pentaho with Gmail, you need to set Gmail to "allow connections from less secure applications".

Gmail account authentication error while sending mail in android application

I am getting following error when i am trying to send message from android application with gmailapi.
"Could not connect to SMTP host: relay.jangosmtp.net, port: 465, response: -1"
Since 2015 google is not allowing "less secure apps" to connect through their SMTP port (this means you need a ssl or tls certificate).
To allow them you could try this: https://support.google.com/accounts/answer/6010255?hl=en

Remote host closed connection during handshake exception while sending out mail using Java Mail

I am using Java Mail API Ver. 1.4.2 for sending out email in JSF 1.2-Spring based Web Application. I am using non secured SMTP connection for sending out a mail. This email configuration is working fine standalone. Also verified this utility using JUnit 4 test and I am able to send mail using non secure connection.
When I integrate this email module with main web application I am getting following exception at runtime while sending out a mail.
javax.mail.MessagingException: Exception reading response; nested exception is: javax.net.ssl.SSLHandshakeException: Remote host closed
connection during handshake at
com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1764)
at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1523)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453)
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)
Verified this email module using secure SMTP connection and it's working fine.
Anyone having idea on this issue? Why non-secured SMTP connection not working in integration with Web Application?
I am using email module for both secured and non secured connections.
In that following property was causing the issue : props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
Removed this property for non secured connections and now my non-secured SMTP connection is working in integration with Web Application.

Which hostname is required to send email to a user through a website created with Google Apps?

Our website was created with Google Apps.
My website URL is http://mydomain.com, which is pointing to http://sites.google.com/a/mydomain.com/.
I want to send email to a registered user.
I am using the Apache Commons jar to send mail to the user.
I get this error message:
Sending the email to the following server failed : http://mail.google.com/a/mydomain.com:25
I used smtpPortAddress=25 & hostName=http://mail.google.com/a/mydomain.com.
I am not spending money on email server setup, so I want to send email through our website.
Which hostname is required to send mail?
I do not know if you can use port 25, for the encrypted SMTP port you can use
Host: smtp.gmail.com
Port: 465
Authentication: Yes
Username: you#yourdomain.com
Password: #YOUR_PASSWORD#
Security: SSL
Either way, just use smtp.gmail.com with your #yourdomain.com name.
You could use any mail server to sent your mail.
But if you like to use GMail the server is smtp.gmail.com.
But you also will have to make sure you authenticate as a valid gmail user.

Categories