找到javax.mail.AuthenticationFailedException:连接失败,未指定密码?在收听密码正确的新邮件时

问题描述 投票:0回答:1

此异常是我在使用Spring集成连接imap gmail存储时遇到的。请看一下代码{@自动连线私有IntegrationFlowContext flowContext;

    public void startMail(String user, String pw) {
        IntegrationFlow flow = IntegrationFlows
                .from(Mail.imapIdleAdapter(imapUrl(user, pw))
                        .javaMailProperties(p -> p.put("mail.debug", "true"))
                        //.userFlag("testSIUserFlag") // needed by the SI test server - not needed if server supports /SEEN
                        .headerMapper(new DefaultMailHeaderMapper()))
                .handle(System.out::println)
                .get();
        this.flowContext.registration(flow).register();
    }}

其中imapUrl(user,pw)返回网址为imap://[email protected][email protected]:993 / INBOX

请帮助我摆脱这个例外。

注意:我读了一篇文章here,说需要在凭据中转义'@'。作为Java Spring Boot的新手,请让我知道我如何转义'@'

java spring-integration dsl
1个回答
0
投票

默认情况下,GMail不支持JavaMail客户端;您必须启用“安全性较低的客户端”(或类似功能)。

使用%40替换@

https://www.werockyourweb.com/url-escape-characters/

© www.soinside.com 2019 - 2024. All rights reserved.