Hi,
in james trunk (development version). you could inject the
UsersRepository in your mailet and just add the user if it not exists.
But you will need to use development version.
Something like this should work (not tested):
public class AddUserOnFlyMailet extends GenericMailet{
private UsersRepository repository;
private MailServer server;
@Resource(name="localusersrepository")
public void setUsersRepository(UsersRepository repository) {
this.repository = repository;
}
@Resource(name="James")
public void setMailServer(MailServer server) {
this.server = server;
}
@Override
public void service(Mail mail) throws MessagingException {
Iterator<MailAddress> rcpts = mail.getRecipients().iterator();
while (rcpts.hasNext()) {
MailAddress rcpt = rcpts.next();
String username;
if (server.supportVirtualHosting()) {
// use the full email address as username
username = rcpt.toString();
} else {
// use only the local part
username = rcpt.getLocalPart();
}
if (repository.contains(username) == false) {
repository.addUser(username, "secret");
}
}
}
}
Hope it helps,
Norman
Ps: We are currently plan to release a milestone of current trunk
within the next weeks
2010/4/29 mil batukada <[email protected]>:
> Hi ,
>
> does anybody know how can I add users on the fly ( i.e if an email arrives
> with a recipient that has no inbox, that user account does no exist ),
> without using the telnet stuff ?
>
> thx,
>
> mil batukada
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]