Preparations for the Send-As-Email DocLib action - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License
  1. Add a project with a repository Action that can send emails with attachments.

    This tutorial assumes that we have a repository Action available that can send emails with attachments. Currently the out-the-box mail repository action cannot send emails with attachments. So we need to include another custom Repo action that can do this. The SDK sample code has a repository JAR project with such an action that we can use.

    Copy the whole add-action-repo JAR project into your All-In-One project. Then include it in the repository WAR project by updating the aio/pom.xml file as follows:

       <plugin>
         <groupId>org.alfresco.maven.plugin</groupId>
         <artifactId>alfresco-maven-plugin</artifactId>
         <version>${alfresco.sdk.version}</version>
            ...
            <platformModules>
              <!-- Share Services will be ignored if you are on Platform earlier than 5.1 -->
              <moduleDependency>
                  <groupId>${alfresco.groupId}</groupId>
                  <artifactId>alfresco-share-services</artifactId>
                  <version>${alfresco.share.version}</version>
                  <type>amp</type>
              </moduleDependency>
    
              <!-- Bring in custom Modules -->
              <moduleDependency>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>aio-platform-jar</artifactId>
                  <version>${project.version}</version>
              </moduleDependency>
    
              <moduleDependency>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>add-action-repo</artifactId>
                  <version>${project.version}</version>
              </moduleDependency>
    
              <!-- Bring in the integration tests -->
              <moduleDependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>integration-tests</artifactId>
                 <version>${project.version}</version>
                 <classifier>tests</classifier>
               </moduleDependency>
            </platformModules>
    

    A repository action with the send-as-email ID is now available and we can call it from a DocLib action. It takes three parameters as can be seen in the implementation:

    publicclassSendAsEmailActionExecuterextendsActionExecuterAbstractBase {
        privatestatic Log logger = LogFactory.getLog(SendAsEmailActionExecuter.class);
    
        publicstaticfinal String PARAM_EMAIL_TO_NAME = "to";
        publicstaticfinal String PARAM_EMAIL_SUBJECT_NAME = "subject";
        publicstaticfinal String PARAM_EMAIL_BODY_NAME = "body_text";
    
        ...
    
        @Override
        protectedvoidaddParameterDefinitions(List<ParameterDefinition> paramList) {
            for (String s : new String[]{PARAM_EMAIL_TO_NAME, PARAM_EMAIL_SUBJECT_NAME, PARAM_EMAIL_BODY_NAME}) {
                paramList.add(new ParameterDefinitionImpl(s, DataTypeDefinition.TEXT, true, getParamDisplayLabel(s)));
            }
        }
    
    Our Send-As-Email DocLib action will collect the values for these three parameters via a form.
  2. Start up the SMTP Server

    After downloading the FakeSMTP server, see link in the beginning of this tutorial, unpack and then start it with the following command:

    martin@gravitonian:~/apps/fakeSMTP$ java -jar fakeSMTP-1.13.jar -s -p 2525
    

    It should start up immediately and listen on port 2525, you should see a UI that will display any incoming emails.