Próbuję wysłać majla takim kodem:
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "poczta.o2.pl");
props.setProperty("mail.user", "xxx");
props.setProperty("mail.password", "xxx");
Session mailSession = Session.getDefaultInstance(props, null);
Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
message.setSubject("Testing javamail plain");
message.setContent("This is a test", "text/plain");
message.addRecipient(Message.RecipientType.TO,
new InternetAddress("[email protected]"));
transport.connect();
transport.sendMessage(message,
message.getRecipients(Message.RecipientType.TO));
transport.close();
Działa super, ale wymaga autoryzacji poczta.o2.pl, wyskakuje błąd :
Sender address rejected: SERWER poczta.o2.pl WYMAGA UWIERZYTELNIENIA. Zobacz http://pomoc.o2.pl/poczta/autoryzacja/ i skonfiguruj poprawnie program pocztowy.
Jak ustawić autoryzację w JaVIe ???
a może znacie konta pocztowe nie wymagające autoryzacji, chociaż to już nie to samo :-/