40 Set<String> ids =
new HashSet<>();
41 MailProviderSet
set =
new MailProviderSet();
42 List<String> names =
new ArrayList<>();
43 names.add(
"IMailMessagePool");
44 names.addAll(ContextFactory.getImplementationNamesByType(
"IMailMessagePool"));
45 names.forEach((s) -> {
46 MailMessagePool pool = (MailMessagePool) HeadlessApplication.getInstance().getImplementation((String) s);
47 MailProvider provider =
new MailProvider();
48 KeyValueMap attrs = pool.getAttributes();
49 String
id = ((String) s).substring(((String) s).indexOf(
"_") + 1);
50 if(
"IMailMessagePool".equals(
id))
id = MailProviders.GENERIC;
51 if(!ids.contains(
id)) {
53 provider.setHostname(attrs.get(
"mailhost"));
54 provider.setPort(attrs.get(Integer.class,
"port",
null));
55 provider.setTls(attrs.get(Boolean.class,
"tls",
false));
56 provider.setSsl(attrs.get(Boolean.class,
"ssl",
false));
57 provider.setUser(attrs.get(String.class,
"user",
null));
58 provider.setPassword(attrs.get(String.class,
"cryptpass",
null));
59 if(Strings.isBlank(provider.getPassword())) {
60 provider.setPassword(ElephantContext.encrypt(attrs.get(String.class,
"password",
null)));
62 provider.setFrom(MailRecipient.of(attrs.get(String.class,
"from",
null)));
63 provider.clearEmpties();
64 set.addProvider(provider);
68 ContextFactory.getImplementationNamesByType(
"IMailPool").forEach((s) -> {
69 MailPool pool = (MailPool) HeadlessApplication.getInstance().getImplementation((String) s);
70 MailProvider provider =
new MailProvider();
71 KeyValueMap attrs = pool.getAttributes();
72 String
id = ((String) s).substring(((String) s).indexOf(
"_") + 1);
73 if(!ids.contains(
id)) {
75 provider.setHostname(attrs.get(
"mailhost"));
76 provider.setPort(attrs.get(Integer.class,
"port",
null));
77 provider.setTls(attrs.get(Boolean.class,
"tls",
false));
78 provider.setSsl(attrs.get(Boolean.class,
"ssl",
false));
79 provider.setUser(attrs.get(String.class,
"user",
null));
80 provider.setPassword(attrs.get(String.class,
"cryptpass",
null));
81 if(Strings.isBlank(provider.getPassword())) {
82 provider.setPassword(ElephantContext.encrypt(attrs.get(String.class,
"password",
null)));
84 provider.setFrom(MailRecipient.of(attrs.get(String.class,
"from",
null)));
85 provider.clearEmpties();
86 set.addProvider(provider);