我有託管帳戶,以我公司的Gmail電子郵件,我試圖從該帳戶在java中發送郵件,但現在面臨以下錯誤:發送使用特定的Gmail從Java的電子郵件accont
javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbsF
534-5.7.14 i7ZvgRt2ia4HE_atVycPueORguLHg4yVG6hw_JGdAgbyUkBfJySVDR_XvkzLZzQp88F-UN
534-5.7.14 aoGU0uN-UBUR91zW7jsbzeq8Ojr6FEjFQcpsVKpv9GLaUPY3ee-pUk3Y6eNABFeA8DgDlu
534-5.7.14 fNDQwLg_R1I5-veyWJ8qE73R833F8PHWFuRanCjTkyPjQogqO-VrBG6omrZHsP3I-8Wphr
534-5.7.14 AjvaiqquhwnrUrmKjyk6RKaJnYaiA> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 w77sm17182835wmw.10 - gsmtp
,這裏是屬性用我的代碼:
final String username = "[email protected]";
final String password = "********";
final String host = "smtp.gmail.com";
final String port = "587";
// Creating Properties object
Properties props = new Properties();
// Defining properties
props.put("mail.smtp.host", host);
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.user", username);
props.put("mail.password", password);
props.put("mail.port", port);
// Authorized the Session object.
Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
所以要清楚,我的電子郵件是([email protected])和mycompany.com的電子郵件Gmail的託管。 如果我用Gmail電子郵件([email protected])替換我的電子郵件,它可以正常工作,那麼這裏有什麼問題以及如何解決。
許多下面的建議是錯誤的,只是使代碼更復雜。查看[常見的JavaMail錯誤]列表(http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes)。你按照錯誤消息的指示,[你的瀏覽器登錄](https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbsFi7ZvgRt2ia4HE_atVycPueORguLHg4yVG6hw_JGdAgbyUkBfJySVDR_XvkzLZzQp88F-UNaoGU0uN-UBUR91zW7jsbzeq8Ojr6FEjFQcpsVKpv9GLaUPY3ee-pUk3Y6eNABFeA8DgDlufNDQwLg_R1I5-veyWJ8qE73R833F8PHWFuRanCjTkyPjQogqO-VrBG6omrZHsP3I-8WphrAjvaiqquhwnrUrmKjyk6RKaJnYaiA )? –
是的,我做了,但沒有發生任何事 –