简体   繁体   English

如何在java中发送ZOHO SMTP服务器邮件?

[英]How to send ZOHO SMTP server mail in java?

I have been using ZOHO SMTP server for sending out email.我一直在使用 ZOHO SMTP 服务器发送电子邮件。 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..但它在本地主机服务器上工作,当将我的代码部署到 AWS 服务器时它不会工作,它给出如下异常..

javax.mail.MessagingException: Could not connect to SMTP host: smtp.zoho.com, port: 465; javax.mail.MessagingException:无法连接到 SMTP 主机:smtp.zoho.com,端口:465; nested exception is: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)嵌套异常是:javax.net.ssl.SSLHandshakeException:没有合适的协议(协议被禁用或密码套件不合适)

My java code is :-我的Java代码是:-

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).上面的代码在我的本地主机服务器(Tomcat)中工作。 can any one please help to solve out this.任何人都可以帮助解决这个问题。

465 is SSL port. 465 是 SSL 端口。 It looks like SSL certificate from ZOHO is missing in AWS. AWS 中似乎缺少来自 ZOHO 的 SSL 证书。 Download/obtain certificate from Zoho and import it on AWS's Keystore.从 Zoho 下载/获取证书并将其导入 AWS 的密钥库。 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.从类似问题和可能的解决方案中检查https://help.zoho.com/portal/community/topic/ssl-security-certificate-updated-pop-imap-and-smtp-servers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM