I've got an object which is a new MimeMessage called message and I want to find out what it's passing to my outgoing mail server. I however have no idea how one gets a variable like this printed out in Java. Here's some code:
private String sendConfirmationEmail (String to, String from, String subject, String body, boolean CCSender) {
try
{
// String smtpHost = Properties.smtp;
String smtpHost = Properties.smtp;
String fromAddress = from;
String toAddress = to;
Properties properties = System.getProperties();
properties.put("mail.smtp.host", smtpHost);
Session session = Session.getInstance(properties, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress));
message.setRecipient(Message.RecipientType.TO,
new InternetAddress(toAddress));
if (CCSender) {
message.setRecipient(Message.RecipientType.CC,
new InternetAddress(from));
}
message.setSubject(subject);
message.setText(body);
System.out.println(message); <=== I want this to work!
message.saveChanges();
Transport.send(message);
return "1:success";
}
catch(Exception e)
{
return "0:failure "+e.toString();
}
}
Any help would be much appreciated.
Thanks.