I see that RemoteDelivery does this:

String name = mail.getName();
for (Iterator i = targets.keySet().iterator(); i.hasNext(); ) {
    String host = (String) i.next();
    Collection rec = (Collection) targets.get(host);
    if (isDebug) {
        StringBuffer logMessageBuffer =
            new StringBuffer(128)
                    .append("Sending mail to ")
                    .append(rec)
                    .append(" on host ")
                    .append(host);
        log(logMessageBuffer.toString());
    }
    mail.setRecipients(rec);
    StringBuffer nameBuffer =
        new StringBuffer(128)
                .append(name)
                .append("-to-")
                .append(host);
    mail.setName(nameBuffer.toString());
    outgoing.store(mail);
}

Please note that at every iteration the same "mail" instance is changed and
stored in the repository with a new name.

Is this a supported way to handle Mailets Mail objects? Wouldn't be more
correct to clone the original mail at each iteration, assigning the new name
in the duplicate method and setting its recipients before storing it?

Currently it works fine because RemoteDelivery does not support passthrough
and because we use the setName that is not and should not be available via
Mail interface.

We should pay attention to this issues when talking about the new mailet
API.

Stefano

Reply via email to