// The real message blob, for example "xmlBlasterMessage.xbf"
String payloadFileName = this.payloadFileNamePrefix +
msgInfo.getMsgInfoParser(getMsgInfoParserClassName(), pluginConfig).getExtension(isCompressed);
InternetAddress toAddr = this.toAddress;
String to = (String)msgInfo.getBounceObject(BOUNCE_MAILTO_KEY);
if (to != null) {
try { // The EmailDriver has different destinations for each client
toAddr = new InternetAddress(to);
} catch (AddressException e) {
log.warning("Illegal 'to' address '" + to + "'");
}
}
if (toAddr == null) {
Thread.dumpStack();
throw new IllegalArgumentException("No 'toAddress' email address is given, can't send mail: " + MsgInfo.toLiteral(msgInfo.createRawMsg(getMsgInfoParserClassName())));
}
EmailData emailData = new EmailData(toAddr, this.fromAddress, subject);
emailData.setCc(this.cc);
emailData.setBcc(this.bcc);
emailData.setExpiryTime(expiryTimestamp);
String payloadMimetype = msgInfo.getMsgInfoParser(getMsgInfoParserClassName(), pluginConfig).getMimetype(isCompressed);
emailData.addAttachment(new AttachmentHolder(payloadFileName, payloadMimetype, payload));
emailData.addAttachment(new AttachmentHolder(this.messageIdFileName, messageId));
// Bounce all other attachments back to sender
AttachmentHolder[] attachments = msgInfo.getBounceAttachments();
for (int i=0; i<attachments.length; i++) {
AttachmentHolder a = attachments[i];
if (this.messageIdFileName.equals(a.getFileName()))
continue; // added alread, see above
emailData.addAttachment(a);
}
getSmtpClient().sendEmail(emailData, messageIdFileName);
//this.smtpClient.sendEmail(this.fromAddress, toAddr, subject,
// attachmentName, attachment, attachmentName2, messageId,
// Constants.UTF8_ENCODING);
if (log.isLoggable(Level.FINE)) log.fine("Sending email from="
+ this.fromAddress.toString() + " to=" + toAddr.toString()
+ " messageId=" + messageId
+ " done");
if (log.isLoggable(Level.FINEST)) log.finest("MsgInfo dump: " + MsgInfo.toLiteral(msgInfo.createRawMsg(getMsgInfoParserClassName())));
}