Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
org.springframework.mail.MailAuthenticationException:身份验证失败;嵌套异常为javax.mail.AuthenticationFailedException_Java_Spring_Email_Spring Mvc - Fatal编程技术网

org.springframework.mail.MailAuthenticationException:身份验证失败;嵌套异常为javax.mail.AuthenticationFailedException

org.springframework.mail.MailAuthenticationException:身份验证失败;嵌套异常为javax.mail.AuthenticationFailedException,java,spring,email,spring-mvc,Java,Spring,Email,Spring Mvc,我被困住了。请帮我解决它的作用。我还将配置为不太安全,并使用此方法传递的内容helper.setFrom(“这里我有一个问题.?” 这是我的dispatcherservlet.xml: <bean> <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="smtp.gmail.com" /&

我被困住了。请帮我解决它的作用。我还将配置为不太安全,并使用此方法传递的内容
helper.setFrom(“这里我有一个问题.?”

这是我的
dispatcherservlet.xml

<bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="smtp.gmail.com" />
    <property name="port" value="587" />
    <property name="username" value="skent.qc@gmail.com" />
    <property name="password" value="password" />

    <!-- The name of the property, following JavaBean naming conventions -->
    <property name="javaMailProperties">
        <props>
            <prop key="mail.transport.protocol">smtp</prop>
            <prop key="mail.smtp.auth">true</prop>
            <prop key="mail.smtp.starttls.enable">true</prop>
            <prop key="mail.debug">true</prop>
        </props>
    </property>
这是我的Java文件,我必须从中发送邮件:

try {
    MimeMessage mimeMessage = mailSender.createMimeMessage();
    FileSystemResource file = new FileSystemResource(HomeAppUtil.getPathForImage() + "/Invoice_" + tblInvoice.getInvoiceId() + ".pdf");

    log.debug("this is sendEmail method in ProviderServiceImpl class 4");

    MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "utf-8");

    helper.setTo(emailId);  
    helper.setSubject(subject);
    helper.setText(message, message);
    helper.addAttachment(file.getFilename(), file);
    System.out.println(file.toString());

    mailSender.send(mimeMessage);
    System.out.println("message send success");
}
catch (Exception e) {
    log.debug("Error message "+e);
}

尝试使用不同的smtp端口或更改传输协议@Omkar我已经尝试使用25个端口,但仍然会引发相同的异常。如果你有其他想法,请指导我。
try {
    MimeMessage mimeMessage = mailSender.createMimeMessage();
    FileSystemResource file = new FileSystemResource(HomeAppUtil.getPathForImage() + "/Invoice_" + tblInvoice.getInvoiceId() + ".pdf");

    log.debug("this is sendEmail method in ProviderServiceImpl class 4");

    MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "utf-8");

    helper.setTo(emailId);  
    helper.setSubject(subject);
    helper.setText(message, message);
    helper.addAttachment(file.getFilename(), file);
    System.out.println(file.toString());

    mailSender.send(mimeMessage);
    System.out.println("message send success");
}
catch (Exception e) {
    log.debug("Error message "+e);
}