Registration emails confirmations configurations

Hello!

And my best wishes for this end of year!

After solving these last two days, the question asked last summer (I had to delay the action): XWiki Debian 17.6.0 : profile pages protection

I would now want to fine-tune the configuration for the registration emails.

What is missing : Emails received (using a test user) miss a subject, and the variables I have tried to use, for the links are not replaced by a value.

How can I fix it?

Here is a reminder of my setup:

  • Debian 12 server
  • XWiki Stable (sources in sources.list.d)
  • Version 17.10.0
  • with: pgsql and xjetty

What I achieved so far : Emails for registration and confirmation are working (Invitations still need testing).

I enclose a screenshot, and if needed, I can be back with the full content for each message field.

How should I proceed to get topics in the messages sent from any of these actions? And how should I do the setup to get the right links in the messages?

PS: The ‘Welcome Message’ displayed on-screen after a successful registration seems to ignore my custom changes in the Administration UI and continues to show the default system message instead.

Hello,

I just updated to XWiki Stable 17.10.2. I just wanted to say, for the context of my issue.

I tried the documentation, tried searches on the web, and also 3 different IAs. Nothing more so far.
I hope someone here can help me solve it.

I finished configuring the Invitations.

For an external SMTP, I found these lines to work (just what is in the XWiki documentation was not enough)

mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.smtp.starttls.required=true
mail.smtp.from=my-mail-id@my-domain.com
mail.smtp.localhost=xwiki.linuxvillage.org

(The SMTP I used is the one from IONOS, where I have a pair of emails).

Tomorrow I will re-check and test again the other registration confirmation emails, with configurations changed, using a text mode extraction from the screenshots provided in the documentation.

Since I didn’t get any feedback, I decided to deep dive into the configuration myself. I finally managed to get everything working perfectly. I am sharing my results below—including text versions of the documentation’s screenshots—to help others and hopefully help improve the official documentation. I’m marking this as Solved.

This is how I restarted the work on the configuration on the registration emails a few days ago : I started with the screenshots on the documentation page, fed them to an IA to get a text version which I was able to copy/paste into the field. From there, I tested, and asked the AI to help me change the contents in the different configuration fields, while registering a test user and removing it, test after test, and same for an invited test user.

Now it all works, except an image that does not show, once the test user invited accepts the invitation.

The name of the image appears, only : it is registration_success_hero.svg.

So, the AI helped me try to find where it is hidden, in the XWiki directories, in the XWiki binary files, no way. (In details: I checked the Skin Extension (SSX) and the standard resources folder, but the mapping for this specific SVG seems to be missing in the registration success display logic).

I created a file, named it, made it compatible (no png inside), tried to make it seen, no way either.

It is not a big issue, but it would look nicer. here is a copy, in case the XWiki team could do something about it, maybe tell me how to make it show, or maybe use it for the next 17.10.*. registration_success_hero.svg - Nextcloud (382,8 Kio)

Next, I’d like to talk in details on how I solved my issue.

Registration page configuration

Under *Next, set “Use email verification” to “YES” which means that an email will be sent to the email address the user registered with. The content of the message is set in the “Validation E-Mail Content” text area." there is this image:


Would it be possible to add the text from the image as text, under the screenshot?

Here is the text (extracted by AI) :

#set ($wikiname = $request.serverName)
#set ($host = ${request.getRequestURL()})
#set ($host = ${host.substring(0, ${host.indexOf('/',
${mathtool.add(${host.indexOf('//')}, 2)})})})
Content-Type: text/plain; charset=utf-8
Subject: Validate your account on ${wikiname}

Hello ${xwiki.getUserName("XWiki.$xwikiname", false)},

This email address was used to register a new account on ${wikiname}. If you did not make the request, please ignore this message.

In order to activate your account, please follow this link:
${host}${xwiki.getURL('XWiki.AccountValidation', 'view', "validkey=${validkey}&xwikiname=${xwikiname}")}

After testing, in order to have it in French and in English, and working for me, this is what I used:

#set ($wikiname = $request.serverName)
#set ($host = ${request.getRequestURL()})
#set ($host = ${host.substring(0, ${host.indexOf('/', ${mathtool.add(${host.indexOf('//')}, 2)})})})
#set ($display = $xwiki.getUserName("XWiki.${xwikiname}", false))
Content-Type: text/plain; charset=utf-8
Subject: Validez votre compte / Validate your account - ${wikiname}

Bonjour ${display},

Votre demande d'inscription a bien Ă©tĂ© enregistrĂ©e. Un e-mail de validation vient de vous ĂȘtre envoyĂ©. 

Veuillez cliquer sur le lien ci-dessous pour activer votre compte avant de vous connecter :

---

Hello ${display},

Your registration request has been recorded. A validation email has been sent to you. 

Please click the link below to activate your account before logging in:

${host}${xwiki.getURL('XWiki.AccountValidation', 'view', "validkey=${validkey}&xwikiname=${xwikiname}")}

(I had tried to have the message provided in both languages using the internal localization method, but it would not work, and this is also a topic for another post/help request coming soon).

After Registration Options

  • Registration page heading is the line displayed at the top of the page for the users who are registering or who have just registered.

  • Confirmation E-Mail Content requires that you set “Use email verification”. These settings are optional but you will still have to provide a link to activate the account."

There is this image: https://www.xwiki.org/xwiki/bin/download/Documentation/AdminGuide/Access%20Rights/Public%20Wiki%20with%20confirmed%20registration/WebHome/ConfirmationEmailContent.png?rev=1.2

#set ($wikiname = $request.serverName)
#set ($host = ${request.getRequestURL()})
#set ($host = ${host.substring(0, ${host.indexOf('/',
${mathtool.add(${host.indexOf('//')}, 2)})})})
Content-Type: text/plain; charset=utf-8
Subject: Your account on ${wikiname} has been activated

Hello ${xwiki.getUserName("$xwikiname", false)},

Your account on ${wikiname} has been successfully activated. You can now login at
${host}${xwiki.getURL('XWiki.XWikiLogin', 'login')} using your username
(${xwiki.getDocument($xwikiname).documentReference.name}).

For this one, I replaced it with this (all are going to be in English and in French) :

#set ($wikiname = $request.serverName)
#set ($host = ${request.getRequestURL()})
#set ($host = ${host.substring(0, ${host.indexOf('/', ${mathtool.add(${host.indexOf('//')}, 2)})})})
#set ($display = $xwiki.getUserName("XWiki.${xwikiname}", false))
## Cette ligne enlĂšve le "XWiki." pour ne garder que le login pur
#set ($cleanUsername = $xwikiname.replaceAll("XWiki\.", ""))
Content-Type: text/plain; charset=utf-8
Subject: Activation de compte / Account activation - ${wikiname}

Bonjour ${display},

Votre compte sur ${wikiname} a été activé avec succÚs. Vous pouvez maintenant vous connecter.

---

Hello ${display},

Your account on ${wikiname} has been successfully activated. You can now login.

Lien de connexion / Login link:
${host}${xwiki.getURL('XWiki.XWikiLogin', 'login')}

Identifiant / Username: ${cleanUsername}

Then there is the Welcome message (but in the admin board, it is the Invitation message that comes before, however here I’ll follow the order from the documentation)

Welcome Message requires that you set “User email verification” to “YES” and modify the “Validation E-Mail Content” so that it doesn’t mention the verification since it is not needed anymore.

This image: https://www.xwiki.org/xwiki/bin/download/Documentation/AdminGuide/Access%20Rights/Public%20Wiki%20with%20confirmed%20registration/WebHome/WelcomeMessage.png?rev=1.2

Contains this text:

$services.localization.render('core.register.title')

And this one:

{{translation key="core.register.welcome"/}}

I did no modification in my configuration for the Welcome Message.

In the Registration page, just before the Welcome message part, and not mentioned in the related XWiki documentation page, there is:

Invitation email content
Email template that will be sent to users invited to register.

This is what I inserted there:

#set ($wikiname = $request.serverName)
#set ($host = ${request.getRequestURL()})
#set ($host = ${host.substring(0, ${host.indexOf('/', ${mathtool.add(${host.indexOf('//')}, 2)})})})
#set ($sender = $xwiki.getUserName($xcontext.user, false))
Content-Type: text/plain; charset=utf-8
Subject: Invitation - Wiki ${wikiname}

Bonjour,

Vous avez été invité par ${sender} à rejoindre le wiki ${wikiname}.

Pour accepter cette invitation et créer votre compte, veuillez cliquer sur le lien ci-dessous :

---

Hello,

You have been invited by ${sender} to join the ${wikiname} wiki.

To accept this invitation and create your account, please follow the link below:

${host}${xwiki.getURL('XWiki.Registration', 'view', "invite=${invitekey}&xwikiname=${wikiname}")}

Then there is still this part (not in the XWiki related documentation page either) :

Registration success message
Displayed to the user at the end of the registration process. You can use Velocity code.

I inserted this:

#set($discard = $xwiki.ssx.use("XWiki.RegistrationConfig"))
#set($displayName = "$!firstName $!lastName")
#if($displayName.trim() == "")
  #set($displayName = $userName)
#end

[[image:registration_success_hero.svg||data-xwiki-image-style-alignment="center" height="50vh"]]

{{html}}
#if($xcontext.locale == 'fr')
<div class="registration-success-headline">
    <h2>Merci $escapetool.xml($displayName) !</h2>
    <p class="registration-success-hint">
      <strong>Votre demande d'inscription a bien été enregistrée.</strong><br/>
      Un e-mail de validation vient de vous ĂȘtre envoyĂ©. Veuillez cliquer sur le lien qu'il contient pour activer votre compte avant de vous connecter.
    </p>
</div>
#else
<div class="registration-success-headline">
    <h2>Thank you $escapetool.xml($displayName) !</h2>
    <p class="registration-success-hint">
      <strong>Your registration request has been recorded.</strong><br/>
      A validation email has been sent to you. Please click the link in that email to activate your account before logging in.
    </p>
</div>
#end
{{/html}}

Then, the Invitations

Invitation Application Page

Here is the documentation : https://extensions.xwiki.org/xwiki/bin/view/Extension/Invitation%20Application

Under EMAIL SUBJECT LINE TEMPLATE we can read:

{{velocity}}$services.localization.render('xe.invitation.emailContent.subjectLine', [$xcontext.getUser().replace('XWiki.', '')]) {{/velocity}}

Under EMAIL MESSAGE BODY HTML TEMPLATE we can read:

{{velocity}}
#set($discard = "#template('colorThemeInit.vm')")
#if("$!theme" == "")
  #set($theme = {"linkColor":"#4791BC"})
#end
#set($userName = $xwiki.getUserName($xcontext.getUser(), false))
#set($wikiName = $xwiki.getRequestURL().replaceAll("http://([^/:]*).*$", "$1")),

In the XWiki of Linuxvillage, this is what I have inserted:

Model for the object of the message:

{{velocity}} $xwiki.getPlainUserName($xcontext.user) vous invite Ă  rejoindre le wiki de Linuxvillage / invites you to join the Linuxvillage wiki {{/velocity}}

Model for the body of the message:

{{velocity}}
#set($discard = "#template('colorThemeInit.vm')")
#if("$!theme" == "")
 #set($theme = {"linkColor":"#4791BC", "notificationErrorColor":"#ca302c"})
#end
#set($userName = $xwiki.getUserName($xcontext.getUser(), false))
#set($wikiName = $xwiki.getRequestURL().replaceAll("http://([^/:]*).*$", "$1"))
#set($guestActionsURL = $xwiki.getDocumentAsAuthor($config.get("guestsActionsPage")).getExternalURL())
#set($linkStyle = "color:$theme.get('linkColor');text-decoration:none;")
#set($bigText = "font-size:130%;")
#set($joinLink = "float:left;")
#set($dangerColor = $theme.notificationErrorColor)
#set($declineLink = "color:$dangerColor;float:right;text-decoration:none;")

$services.localization.render('xe.invitation.emailContent.userHasInvitedYouToJoinWiki', [$userName, $wikiName])

{{html clean=false}}
#if("$!messageBody" != "")
  <p style="$bigText">
  $!escapetool.xml($!messageBody)
  </p>
#end
<p style="margin-top:30px">
<a href="${guestActionsURL}?doAction_accept=y&amp;messageID=$messageID" style="$bigText$joinLink$linkStyle">
$services.localization.render('xe.invitation.emailContent.joinLink')
</a>
<a href="${guestActionsURL}?doAction_decline=y&amp;messageID=$messageID" style="$bigText$declineLink">
 $services.localization.render('xe.invitation.emailContent.declineLink')
</a></p>
<hr style="clear:both" />
$services.localization.render('xe.invitation.emailContent.reportMessage', ["<a href=$escapetool.getQ()${guestActionsURL}?doAction_report=y&amp;messageID=$messageID$escapetool.getQ() style=$escapetool.getQ()$linkStyle$escapetool.getQ()>", "</a>"])
{{/html}}
{{/velocity}}

I am not a Velocity developer, so I worked iteratively with an AI to generate and test these templates. I conducted several ‘live’ tests by registering, inviting, and deleting test users as I went, ensuring each step was functional before moving to the next.

1 Like