email - 由 : javax.net.ssl.SSLException : Unrecognized SSL message, 明文连接引起?

标签 email spring-boot

在尝试连接到圆形立方体时,使用 Spring Boot 设置电子邮件服务时出现以下错误:

Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

这让我认为 roundcude 没有使用 SSL 连接,并且我不应该使用端口 143。因此我尝试使用端口 25,但这样做时出现以下错误。

Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

应用程序属性

#email setup
spring.mail.host = mail.email address.com
spring.mail.username = email address
spring.mail.password = my password

spring.mail.properties.mail.smtp.auth= true
spring.mail.port = 25 or port 145
spring.mail.properties.mail.smtp.socketFactory.class= javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socketFactory.fallback= false
spring.mail.properties.mail.smtp.ssl.enable = true

电子邮件服务

@Component
public class EmailServiceImpl implements EmailService {

    @Autowired
    private JavaMailSender javaMailSender;

    @Override
    public void sendEmail(String toAddress, String fromAddress,
                          String subject, String body) {

        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();

        simpleMailMessage.setFrom(fromAddress);
        simpleMailMessage.setTo(toAddress);
        simpleMailMessage.setSubject(subject);
        simpleMailMessage.setText(body);

        javaMailSender.send(simpleMailMessage);

    }
}

我查看了 roundcube 的文档,显然它使用端口 143,所以这相当令人困惑。这让我觉得我设置错误。

我也尝试过 gmail,但由于我有两因素身份验证,所以我遇到了更多问题,所以我决定使用 roundcube,无论如何,这是我更愿意使用的。

建议?

最佳答案

您似乎正在尝试使用非安全端口连接到 SMTP。通常安全端口是 587 或 465。

这是适合我使用 GMail 发送电子邮件的配置:

spring.mail.host=smtp.gmail.com
spring.mail.port=587
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2b1b2b0abaca5ecafa3abaeecb7b1a7b0aca3afa7ffafbbefa7afa3abae82a5afa3abaeeca1adaf" rel="noreferrer noopener nofollow">[email protected]</a>
spring.mail.password=my-password
spring.mail.properties.mail.smtp.auth = true
spring.mail.properties.mail.smtp.starttls.enable = true
spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.connectiontimeout = 60000
spring.mail.properties.mail.smtp.timeout = 60000

关于email - 由 : javax.net.ssl.SSLException : Unrecognized SSL message, 明文连接引起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36778717/

相关文章:

hibernate - 如何通过 Spring Data JPA 知道底层数据库名称

java - 巩固 Thymeleaf 中的一对多关系

php - 如何在 Laravel 中使用 sendmail?

spring-boot - 如何将 Spring Boot Logo 更改为 Nyan Cat?

ruby-on-rails - 在Rails中,为什么仅在测试中我的邮件正文为空?

php - SwiftMailer 测试用户名和密码

java - 如何将 Hashmap 传递给 spring data jpa 方法并在更新语句中使用它?

hibernate - 没有名为 'entityManagerFactory' 的可用 bean

使用 SSL 的 Java 邮件 - PKIX 路径验证失败

javascript - 如何将选定复选框的值发送到 app.get 路由