Ciao,
sto cercando di fare inviare delle mail utilizzando Office 365. La connessione sembra avvenire correttamente, ma poi mi ritorna un errore di autenticazione: javax.servlet.ServletException: javax.mail.AuthenticationFailedException
user e password sono sicuramente corretti visto che da outlook mi connetto senza problemi.
Vi riporto il codice che ho scritto in modo che magari trovate qualche cavolata che ho scritto. Grazie a chi mi darà una mano!
[CODE]codice:Properties props = new Properties(); String user = "mail mittente"; String password = "password"; // Set debug so we see the whole communication with the server props.put("mail.debug", "true"); props.put("mail.transport.protocol", "smtp"); props.put("mail.host", outgoingHost); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "587"); // Enable STARTTLS props.put("mail.smtp.starttls.enable", "true"); // Accept only TLS 1.1 and 1.2 props.setProperty("mail.smtp.ssl.protocols", "TLSv1.1 TLSv1.2"); Session session1 = Session.getInstance(props, null); session1.setDebug(true); // Create an SMTP transport from the session SMTPTransport t = (SMTPTransport)session1.getTransport("smtp"); // Connect to the server using credentials t.connect(outgoingHost, user, password); MimeMessage message = new MimeMessage(session1); message.setSubject("AATMI - Credenziali - MIS_MI - RESET"); message.setContent(testo, "text/plain"); MimeMultipart mp = new MimeMultipart(); MimeBodyPart body = new MimeBodyPart(); body.setText(testo, "iso-8859-1", "html"); mp.addBodyPart(body); String filename = directory + "allegato.xls"; FileDataSource source = new FileDataSource(filename); attachment.setDataHandler(new DataHandler(source)); attachment.setFileName("allegato.xls"); mp.addBodyPart(attachment); message.setContent(mp); message.addRecipient(Message.RecipientType.TO, new InternetAddress("mail di destinazione")); t.sendMessage(message, message.getAllRecipients());

					
					
					
						
  Rispondi quotando