I have following code:
private static boolean envioTest(final String descricao, final String msg, final String to)throws MessagingException{
final Properties props = new Properties();
props.put("mail.smtp.host", "64.233.186.108");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
final Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,ps);
}
});
try {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final PrintStream ps = new PrintStream(os);
session.setDebug(true);
session.setDebugOut(ps);
final Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(user));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
message.setSubject(descricao);
message.setText(msg);
System.out.println("Enviando....");
Transport.send(message);
ps.println(); // Deveria imprimir?
return true;
} catch (MessagingException e) {
throw e;
}finally {
System.out.println("\n");
}
}
I would like to know how do I print the shipping information?
I do not really know what to do with PrintStream
.
I've tried ps.println();
but it does not display anything.
Thank you!