Mail config override for subwiki

There seems to be bug in overriding subwiki mail config with main wiki settings if subwiki mail config is not/partially set.

Situation:

  1. mainwiki mail settings - SmtpServer1 with username1/password1
  2. subwiki mail settings - SmtpServer2 with anonymous access (username/password fields empty)

Result:
Subwiki is trying to send mail using SmtpServer2 with username1/password1 resulting in sending error

Expected result:
Subwiki is using SmtpServer2 with anonymous access

(In other words if smtp server on subwiki is set, then always use username/pwd from subwiki)

If you confirm bug I ll create bug issue.

I did not check the code, but I would not be surprised that it does “if empty then fallback on main wiki” for each configuration which indeed seems to means that it’s impossible to have anonymous access on subwiki.

@vmassol can probably confirm.

thanks, just adding real life scenario:

  1. farm uses localhost anonymous smtp server (on both main and subwiki)
  2. there is need to temporarily divert main wikis emails for testing purposes to testing smtp server (in this case mailtrap - with username/password)
  3. this change makes unable for subwikis to still use anonymous access even when smtp server is overriden on subwiki, the username/pwd are not

Note that I’m not discussing the validity of your use case, it makes perfect sense and should be supported. Just not sure if what I indicated is true.

1 Like

What the mail sender API does is what is documented at https://extensions.xwiki.org/xwiki/bin/view/Extension/Mail/MailSenderAPI#HConfiguration

And indeed each property is considered separately from the others.

Thank you, guys! Issue created

FYI, it’s now been fixed, see https://extensions.xwikiorg-node1.xwikisas.com/xwiki/bin/view/Extension/Mail/MailSenderAPI#HConfiguration