我尝试在android中发送邮件,但它给了我错误javax.mail.AuthenticationFailedException

时间:2017-05-29 18:07:18

标签: java android javamail

我尝试使用javax.mail发送电子邮件,但transport.connect()的行是javax.mail.AuthenticationFailedException的原因。

public void sendEmail() throws AddressException, MessagingException {
    Transport transport = mailSession.getTransport("smtp");
    transport.connect(emailHost, fromEmail, fromPassword);
    Log.i("GMail","allrecipients: "+emailMessage.getAllRecipients());
    transport.sendMessage(emailMessage, emailMessage.getAllRecipients());
    transport.close();
    Log.i("GMail", "Email sent successfully.");
}

0 个答案:

没有答案