在 Spring 框架 JavaMailSenderImpl class 中获取 AuthenticationFailedException

Getting AuthenticationFailedException in the Spring Framework JavaMailSenderImpl class

我的 OS X (Maverick) 计算机上有 Spring 框架应用程序。我用gmail。

我们的 Spring 框架应用程序使用 org.springframework.mail.javamail。 JavaMailSenderImpl class 发送电子邮件。这部分代码抛出 AuthenticationFailedException

protected void doSend(MimeMessage[] mimeMessages, Object[] originalMessages) throws MailException {
    Map<Object, Exception> failedMessages = new LinkedHashMap<Object, Exception>();

    Transport transport;
    try {
        transport = getTransport(getSession());
        transport.connect(getHost(), getPort(), getUsername(), getPassword());
    }
    catch (AuthenticationFailedException ex) {
        throw new MailAuthenticationException(ex);
    }

对于主机,我使用 smtp.gmail.com,端口:587。我还使用常规 gmail 登录的用户名和密码。

我有一个具有相同设置的同行,他发送电子邮件有效。

转到 Google 帐户,在 Sign-in 和安全性中需要 允许安全性较低的应用程序 使用 gmail。就是这样