这让我发疯了:)当我在netbeans上编码时,代码运行良好(我的意思是,它成功发送了我想要的所有电子邮件),但是,在Clean and Build之后,它只是不发送任何电子邮件
。zzzzzzzzzzzzzzzzzzzz =我的密码
这是我的sendig代码:
private void envia_email (String email_selecionado) {
String to = email_selecionado;
String from = "xxxxxxxxxx@gmail.com";
Properties properties = new Properties();
properties.put("mail.transport.protocol", "smtp" );
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.port", "587");
properties.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory"); //SSL Factory
try {
Session session = Session.getInstance(properties,
new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(from, "zzzzzzzzzzz");
}
});
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("EUROMILIONS PLAY SOFTWARE");
message.setText(corpo_email.getText());
message.setSentDate(new Date());
Transport.send(message);
//JOptionPane.showMessageDialog(null,"Mensagem enviada com sucesso !");
} catch (MessagingException ex) {
teste.setVisible(false);
JOptionPane.showMessageDialog(this,"Erro: "+ex.toString());
//Logger.getLogger(serial_control.class.getName()).log(Level.SEVERE, null, ex);
}
}
有什么问题?为什么它可以在netbeans上运行,但在Clean and Build之后不能运行。
谢谢