how to send mail using ActionExecuterAbstractBase?

Showing results for 
Search instead for 
Did you mean: 
Active Member

how to send mail using ActionExecuterAbstractBase?

I did this configuration 


In Class 

Properties mailServerProperties = new Properties();
mailServerProperties = System.getProperties();
mailServerProperties.put("", "localhost");
mailServerProperties.put("mail.smtp.port", "25");
Session session = Session.getDefaultInstance(mailServerProperties, null);
Message message = new MimeMessage(session);
String fromAddress = "";
message.setFrom(new InternetAddress(fromAddress));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(""));

// Create the message part with body text
BodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();

// Create the Attachment part
// Get the document content bytes


// Put parts in message


 i am sending email from :  to  
But i am getting this error:
org.alfresco.error.AlfrescoRuntimeException: 06090023 Could not send email: 554 The email address '' does not reference a valid accessible node.
8 Replies

Re: how to send mail using ActionExecuterAbstractBase?

Can you clarify whether you want to send emails without attachments or with attachments ?

There is an action OOTB which allows to send emails to a user or a group but attachment feature is not available as of now. 

This action class extends ActionExecuterAbstractBase as well: org.alfresco.repo.action.executer.MailActionExecuter

Here is sample code snippet using OOTB MailActionExecuter which may be helpful.

private String fromEmailAddress;
private String templateSpace;
private NodeService nodeService;
private ActionService actionService;
private PersonService personService;
private NamespaceService namespaceService;
private SearchService searchService;

//Setter and Getter methods of above items

public void sendEmailToGroupOrEmailId(final String subject,
final String templateString, final Map<String, Serializable> model,
final Serializable recipients) {
//Example snippet Send to group
final ArrayList<Serializable> recipientList = new ArrayList<Serializable>();
if (recipients instanceof ArrayList) {
recipientList.addAll((Collection<Serializable>) recipients);
} else {
final Action action = actionService.createAction(MailActionExecuter.NAME);
action.setParameterValue(MailActionExecuter.PARAM_TO_MANY, recipientList); //A group or email id.
action.setParameterValue(MailActionExecuter.PARAM_FROM, fromEmailAddress); //From address is configured in global properties
action.setParameterValue(MailActionExecuter.PARAM_SUBJECT, subject);
action.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, getMailTemplate(templateString)); //Email template path. e.g. : /Company Home/Data Dictionary/Email Templates/my_operation_email.html.ftl
action.setParameterValue(MailActionExecuter.PARAM_TEMPLATE_MODEL, (Serializable) model); //a map containing parametrers you want to pass within email template.
actionService.executeAction(action, null);

//If you have person's user id, this method will get the email id via its person node and intitiate email action
public void sendEmailToUserId(final String uid, final String subject,
final String templateString, final String message,
final Map<String, Serializable> model) {
final NodeRef personNodeRef = personService.getPerson(uid);
final String email = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_EMAIL);
sendEmailToGroupOrEmailId(subject, templateString, model, email);

private String getMailTemplate(final String templateString) throws SendMailException {
String template = StringUtils.EMPTY;
if(templateString.indexOf('/') == -1) {
template = nodeService.getChildByName(getTemplatesSpace(), ContentModel.ASSOC_CONTAINS, templateString).toString();
} else {
template = templateString;
return template;

private NodeRef getTemplatesSpace() throws SendMailException {
if (templatesSpaceRef == null) {
templatesSpaceRef = selectNodeByDisplayPath(templateSpace);
return templatesSpaceRef;

public NodeRef selectNodeByDisplayPath(final String path)
throws InvalidNodeRefException, XPathException,
IllegalArgumentException {
String nodePath = path;
NodeRef nodeRef = null;
if (path.startsWith("/")) {
nodePath = path.substring(1);

final List<NodeRef> selectedNodes = searchService.selectNodes(nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE),
nodePath, null, namespaceService, false);
if (selectedNodes != null && !selectedNodes.isEmpty()) {
nodeRef = selectedNodes.get(0);
return nodeRef;

Someone has implemented a custom MailExecutorAction by taking the reference of OOTB action class which can send the attachments as well. I have not tested it but you may want to try this:

Active Member

Re: how to send mail  using  ActionExecuterAbstractBase?

Hi Abhinav,

i  want to send a mail using inbound ACS setting to any user .So  i used ActionExecuterAbstractBase to send a mail . 


Re: how to send mail  using  ActionExecuterAbstractBase?

Instead of creating traditional email sender logic/methods and implementing the action. I would suggest to use OOTB way of sending emails. It is also an action which can be executed synchronously/asynchronously. You can use a custom email template with this approach where you can pass some parameters, add custom logo and format as per your liking. It will also support sending email to an Alfresco Group. e.g. GROUP_Administrators. If you pass this value, all the users who are part of this group would receive emails. You don't have to extract each user's email id..

Active Member

Re: how to send mail  using  ActionExecuterAbstractBase?

Any configuration i have to do  for from , host and port  in alfresco global properties 


Re: how to send mail using ActionExecuterAbstractBase?

Yes. you would  need following configurations:

You can bootstratp your email templates to /Company Home/Data Dictionary/Email Templates/ folder and get the template at run time while sending email. You can refer here for bootstrapping template:

You can find the ootb email templates in /Company Home/Data Dictionary/Email Templates/ folder and you can take reference from any of the templates to create your custom template if needed. 

The sample method provided above: getMailTemplate(final String templateString) needs the name of the template file and it returns the full path for the method which uses the template for sending email.. 

e.g. getMailTemplate("my_operation_email.html.ftl")

Active Member

Re: how to send mail using ActionExecuterAbstractBase?

Action mailAction = actionService.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_TO, to);
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, subject);

actionService.executeAction(mailAction, null);

I am not getting any error . But mail is not going 


Re: how to send mail  using  ActionExecuterAbstractBase?

Can you please check all log files including catalina.out log as well. Enable these debug logs and try again to see what error you can find:

Make sure you are not catching any generic exception somewhere which may not be logged. 

Senior Member II

Re: how to send mail using ActionExecuterAbstractBase?

To Send Email,you need to unable outbound email configuration.


ActionService actionService = serviceRegistry.getActionService();

Action mailAction = actionService.createAction(MailActionExecuter.NAME);

mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, subject);

mailAction.setParameterValue(MailActionExecuter.PARAM_TO, email);

actionService.executeAction(mailAction, null); This account must be less sucure app.


Sanjay Bandhniya


Thanks & Regard,