1
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 to get it to print the shipping information???
I don’t really know what to do with the PrintStream
.
I tried a ps.println();
but he displays nothing.
Thank you!
Checks whether System.setOut(ps) is printed on the console.
– adelmo00
No... and still does not display the System.out.println() following
– Thiago Luiz Domacoski
Blz. I’ll see if I can find something and let you know.
– adelmo00
Shipping information? You can specify, what shipping information?
– dougg0k
When Session.setDebug(true); it records some logs on Printstream. I can’t print what he records on this Printstream
– Thiago Luiz Domacoski
I didn’t get it right, you want to print the contents of the ps?
– DiegoAugusto
exactly.....
– Thiago Luiz Domacoski
That one
println()
will just put a line separation on the current line, finishing the line, to print the content doos.toString()
, nay?– Bruno César