Mam taki problem... napisalem sobie applet ktory wysyla email po nacisnieciu przycisku. i wszystko jest ładnie pieknie sie w NetBean'ie kompiluje , uruchamia i nawet tego maila wysyla... problem pojawia sie jak chce to odtworzyc przez przegladarke. Wtedy Java uwaza ze nie zna klasy "Authenticator" :(
W ogole nie mam pojecia o co biega przeciez skoro sie kompiluje to powinno dzialac
class MyAuthenticator extends Authenticator
{
MyAuthenticator() { super(); }
protected PasswordAuthentication getPasswordAuthentication()
{ return new PasswordAuthentication("paul121", "xxx"); }
}
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Properties props = new Properties();
props.put("mail.smtp.host", "poczta.interia.pl");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.auth", "true");
// fill props with any information
Authenticator auth = new MyAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
MimeMessage message = new MimeMessage(session);
message.setContent("Hello", "text/plain");
message.setText("Hello");
message.setSubject("First");
Address address = new InternetAddress("[email protected]");
message.setFrom(address);
Address toAddress = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, toAddress);
Transport transport = session.getTransport("smtp");
transport.connect("poczta.interia.pl", "paul121", "xxx");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}catch (Exception ex) {
ex.printStackTrace();}
// TODO add your handling code here:
}