Witam,
Oto kod metody wysyłającej maile:
public void wyslij() {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", 587);
props.put("mail.smtp.user", "janKowalski");
props.put("mail.smtp.auth", String.valueOf(true));
props.put("mail.smtp.starttls.enable", true);
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("janKowalski", "123456");
}};
Session session = Session.getInstance(props, authenticator);
MimeMessage msg = new MimeMessage(session);
try {
msg.addRecipient(RecipientType.TO, new InternetAddress("[email protected]"));
msg.setSubject("tytul");
msg.setText("wiadomosc");
Transport.send(msg);
}
catch (MessagingException e) {
System.out.println(e);
}
}
Dla gmaila działa, ale dla innych serwerów już nie. Sprawdzałem dla o2 i onet i przy próbie wysłania maila występuje:javax.mail.AuthenticationFailedException 535 Account temporary unavailable
Dlaczego?