Hi @ChrisPhillipsUC
Out of the box AEM does not provide a dedicated "Email" / mailto: button in the RTE.
You can, however, add one reliably with a small custom plugin and config:
1. Allow mailto: links in the RTE
For your Text component, make sure mailto: is allowed under htmlRules:
/apps/your-site/components/content/text/dialog/items/tab1/items/text
- xtype = "richtext"
+ htmlRules
+ links
- protocols (String[]) = ["http://", "https://", "mailto:"]
- defaultProtocol = "http://"
2. Simple custom RTE plugin for "Email"
Create a clientlib, e.g. /apps/your-site/clientlibs/rte-mailto with category cq.authoring.dialog and a JS file:
;(function () {
"use strict";
var RTE = CQ.form.rte;
var FEATURE = "mailtolink";
var MailToPlugin = new Class({
extend: RTE.plugins.Plugin,
getFeatures: function () {
return [FEATURE];
},
initializeUI: function (tbGenerator) {
if (!this.isFeatureEnabled(FEATURE)) {
return;
}
var button = tbGenerator.createElement(FEATURE, this, false, {
title: "Insert email link",
text: "Email"
});
tbGenerator.addElement("links", FEATURE, button, 10);
},
execute: function (id, value, env) {
var ek = this.editorKernel;
var sel = RTE.Selection.getText(env.editContext) || "";
var email = sel.trim();
if (!email || email.indexOf("@") === -1) {
return;
}
if (!/^mailto:/i.test(email)) {
email = "mailto:" + email;
}
ek.execCmd("createlink", email);
}
});
RTE.plugins.PluginRegistry.register(FEATURE, MailToPlugin);
}());
Usage for authors: Select user@domain.com -> click Email -> it becomes <a href="mailto:user@domain.com">user@domain.com</a>.
3. Enable plugin + toolbar button
Under your component's RTE config (in-place + dialog):
.../rtePlugins
+ mailtolink
- features (String[]) = ["mailtolink"]
And in uiSettings toolbar items:
.../uiSettings/cui/toolbars/fullscreen
- items (String[]) = [
"links#modifylink",
"links#mailtolink", // new email button
"links#unlink"
]
After this, authors no longer need to remember mailto:; the plugin wraps the selected email correctly, avoiding http://email@… and broken-link scans.