cancel
Showing results for 
Search instead for 
Did you mean: 

Email notification example

javydreamercsw
Champ in-the-making
Champ in-the-making
I've been reading across the post for how to set up the email for notifications since it seems is not an out-of-the-box feature. I found the following in the System administration manual:

Configuring email
You can configure the Alfresco repository to send e-mails from an SMTP server.
Currently the repository does not support secure SMTP servers. In V1.2 the
mail.username may be anonymous.

The procedure involves:
 Copying part of a default configuration file
 Pasting the snippet into a new file.
 Saving the file in the <extension> directory.
➢ To configure email
1. Browse to the file:
<configRoot>/alfresco/repository.properties
Warning: You are recommended not to directly modify any property in a default file.
2. Copy the following block of email properties:
# Email configuration
mail.host=
mail.port=25
mail.username=anonymous
mail.password=
3. Create a new file in the <extension> directory.
4. Copy the email properties block into this file.
5. Modify any property to your required value as follows (you can delete any
unmodified property, because it will retain the default value from
repository.properties):
mail.host=<the name of your SMTP host>
mail.port=<the port that your SMTP service runs on (the default is
25)>
mail.username=<the username of the account you want e-mail to be sent
from>
mail.password=<the password>
6. Save the file with a meaningful name that ends with .properties
7. Ensure that your new file is pointed to, so that it can be found at server startup
(refer to "About pointing to customized configuration files", on page 7).

I looked into the system and the email properties are already in the repository.properties file. The created an email.properties file with the specified contents and obviously the required values. Here's an example:

mail.host=smtp.google.com
mail.port=587
mail.username=myeamil@gmail.com
mail.password=mypasword

The following the section "About pointing to customized configuration files > Pointing to customized files (non-web client) in <extension>
directory" and added the following line to custom-db-and-data-context.xml


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<!–
       This shows the common minimum configuration overrides.
       By default, the content and indexes are located at a relative location, which should only
       be used when doing a quick preview of the Alfresco server.
–>
<beans>
  
    <!– overriding to point to custom properties –>
    <bean id="repository-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders">
            <value>true</value>
        </property>
        <property name="locations">
            <list>
                <value>classpath:alfresco/repository.properties</value>
                <value>classpath:alfresco/version.properties</value>
                <value>classpath:alfresco/domain/transaction.properties</value>
      <value>classpath:alfresco/email.properties</value>

                <!– Override data location properties –>
                <value>classpath:alfresco/extension/custom-data-location.properties</value>
                <!– Override database connection properties –>
                <value>classpath:alfresco/extension/custom-db-connection.properties</value>
            </list>
        </property>
    </bean>

    <bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:alfresco/domain/hibernate-cfg.properties</value>

                <!– Override hibernate dialect –>
                <value>classpath:alfresco/extension/custom-hibernate-dialect.properties</value>
            </list>
        </property>
    </bean>
   
</beans>

Then restarted the server but no email received after activating a workflow with email actions (the rest of the rules worked).

Any idea and/or example?

Thanks in advance.
3 REPLIES 3

javydreamercsw
Champ in-the-making
Champ in-the-making
Looks like there's an error in the System Administration manual.

I had to change this:


2. Copy the following block of email properties:
# Email configuration
mail.host=
mail.port=25
mail.username=anonymous
mail.password=
3. Create a new file in the <extension> directory.

to this:


2. Copy the following block of email properties:
# Email configuration
mail.host=
mail.port=25
mail.username=anonymous
mail.password=
3. Create a new file in the webapps\alfresco\WEB-INF\classes\alfresco directory.

Why I think it's wrong? I made the changes based in other applications that have automatic email sending. Also I noticed that the file custom-db-and-data-context.xml refers to files in the mentioned directory so I modified the file like this:


<value>classpath:alfresco/repository.properties</value>
                <value>classpath:alfresco/version.properties</value>
<value>classpath:alfresco/email.properties</value>
                <value>classpath:alfresco/domain/transaction.properties</value>

where email.properties is the .properties file created in System Administration instructions.

With this setup I got this error:


14:06:18,197 ERROR [org.alfresco.repo.action.executer.MailActionExecuter] Failed to send email to null
org.springframework.mail.MailSendException: Could not send mails: 530 5.7.0 Must issue a STARTTLS command first r9sm1643478nza

com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first r9sm1643478nza

   at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
   at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
   at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
   at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:382)
   at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:326)
   at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:341)
   at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:330)
   at org.alfresco.repo.action.executer.MailActionExecuter.executeImpl(MailActionExecuter.java:291)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:112)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:524)
   at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:64)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:112)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:524)
   at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:456)
   at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:383)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
   at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:32)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:210)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:156)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
   at $Proxy17.executeAction(Unknown Source)
   at org.alfresco.repo.rule.RuleServiceImpl.executeRule(RuleServiceImpl.java:907)
   at org.alfresco.repo.rule.RuleServiceImpl.executePendingRule(RuleServiceImpl.java:875)
   at org.alfresco.repo.rule.RuleServiceImpl.executePendingRulesImpl(RuleServiceImpl.java:846)
   at org.alfresco.repo.rule.RuleServiceImpl.executePendingRules(RuleServiceImpl.java:819)
   at org.alfresco.repo.rule.RuleTransactionListener.beforeCommit(RuleTransactionListener.java:61)
   at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:585)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:657)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:482)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:469)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:266)
   at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:397)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:92)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
   at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)

I'm checking out the source code to look for the mentioned class (org.alfresco.repo.action.executer.MailActionExecuter).

It should be missing something like this:


props.put("mail.smtp.starttls.enable","true");

If someone can fix it before I do please let me know. I might take some time. I have Netbeans so I must import from Eclipse first…

anfy2002us
Champ in-the-making
Champ in-the-making
The manual says
Currently the repository does not support secure SMTP servers
and Google use secure SMTP for the outgoing mail, so I think that it won't be successfull with GMail.

javydreamercsw
Champ in-the-making
Champ in-the-making
I'm aware of the manual statement. Just requesting for a feature…