javax.mail.AuthenticationFailedException: failed to connect, no password specified?

前端 未结 14 1972
广开言路
广开言路 2020-12-17 10:46

This program attempts to send e-mail but throws a run time exception:

javax.mail.AuthenticationFailedException: failed to connect, no password specified?
         


        
14条回答
  •  轮回少年
    2020-12-17 11:05

    I have just faced this problem, and the solution is that the property "mail.smtp.user" should be your email (not username).

    The example for gmail user:

    properties.put("mail.smtp.starttls.enable", "true");
    properties.put("mail.smtp.host", host);
    properties.put("mail.smtp.user", from);
    properties.put("mail.smtp.password", pass);
    properties.put("mail.smtp.port", "587");
    properties.put("mail.smtp.auth", "true");
    

提交回复
热议问题