[SOLVED]Daily job NOT sending email

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
luiscesarinfo
Active Member II

[SOLVED]Daily job NOT sending email

Hi Guys,

I'm working with Alfresco 5.2 on a AWS Linux environment and I have set a job to run daily at 1am. The job it self is running perfectly but an email that should be sent to the user is not being sent.

Everything seem working fine and when I call "executeAction()" nothing happens.

Testing the code on my development environment, it is working fine and I am getting the email.

To send the email, I'm implementing an Action (see class attached) as below:


private void notifyUser(PersonInfo person, long daysLeft) {

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

    mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Embed software: Password expiration");

    mailAction.setParameterValue(MailActionExecuter.PARAM_TO, serviceRegistry.getNodeService().getProperty(person.getNodeRef(), ContentModel.PROP_EMAIL));

    mailAction.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, getEmailTemplate());

    Map<string, serializable=""> templateArgs = new HashMap<string, serializable="">();

    templateArgs.put("firstname", person.getFirstName());

    templateArgs.put("daysLeft", daysLeft);

    templateArgs.put("username", person.getUserName());

    Map<string, serializable=""> templateModel = new HashMap<string, serializable="">();

    templateModel.put("args",(Serializable)templateArgs);

    mailAction.setParameterValue(MailActionExecuter.PARAM_TEMPLATE_MODEL,(Serializable)templateModel);

    actionService.executeAction(mailAction, null);

}


Any comment welcome.

Regards,

Luis Camargo

3 Replies
cesarista
Advanced

Re: Daily job NOT sending email

Hi:

Is Alfresco log saying something relevant about this? For example, I would use OOTB support tools for increasing the log details while executing the scheduled job (as an action) in support tools.

Typical problems on notifications are related to bad smtp configurations or wrong permissions on Data Dictionary for notification templates. 

Regards. 

--C. 

Moderator
Moderator

Re: Daily job NOT sending email

Check if your SMTP config is correct, try to telnet and check connectivity.

Additionally, Can you put some additional logs in following methods: checkUsersPasswordExpiration(), configUserCredentialsExpiryDate(..) and notifyUser(..)? Additionally, put log in the if block where you are checking the date left value:

if (userExists && isUserEnabled) {
//LOG here
Date credentialsExpiryDate = authenticationDao.getCredentialsExpiryDate(person.getUserName());
if (credentialsExpiryDate == null) {
configUserCredentialsExpiryDate(person);
} else {
//LOG here
long daysLeft = HTHUtil.getDifferenceDaysFromToday(credentialsExpiryDate);
if (daysLeft >= 0 && daysLeft <= 7) {
//LOG here
notifyUser(person, daysLeft);
} else {
}
}
} ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Also, can you enable the debug logs for following:

log4j.logger.org.alfresco.repo.action.executer=debug

log4j.logger.org.alfresco.repo.action.executer.MailActionExecuter=debug

After making these changes, see if you can capture any logs.

luiscesarinfo
Active Member II

Re: [SOLVED]Daily job NOT sending email

Thank you very much Abhinav Mishra‌ and Cesar Capillas‌. 

In the end the problem was a incorrect code on my email template. After I enable the debug logs it was easy to identify the problem.

Thank you very much.

Regards 

Luis Camargo