General Mail API

Version 6.1 by Vincent Massol on 2020/05/11 16:53

cogMail APIs not related to sending emails
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Description

Obfuscation

  • Find out if email obfuscation is on or not:
    • from Java:
      @Inject
      private GeneralMailConfiguration configuration;
      ...
      if (configuration.shouldObfuscate())
      ...
    • From Velocity:
      $services.mail.general.shouldObfuscate()
  • Obfuscate an email address:
    • from Java:
      @Inject
      private EmailAddressObfuscator obfuscator;
      ...
      obfuscator.obfuscate(InternetAddress.parse("john@doe.com")[0])
    • From Velocity:
      #if ($services.mail.general.obfuscate('john@doe.com'))
      ...

HTML Displayer

An HTML Displayer for javax.mail.internet.InternetAddress is available, allowing to display an email address, either obfuscated (if configured, see the Mail Application) or not.

Example usage from Velocity:

{{velocity}}
#set ($email = $services.user.properties.email)
{{html}}
$services.display.html.display('javax.mail.internet.InternetAddress', $email)
{{/html}}
{{/velocity}}

or

{{velocity}}
#set ($email = $services.user.properties.email)
{{html}}
$services.display.html.display($email.class, $email)
{{/html}}
{{/velocity}}

Get Connected