Email notifications for inactive users

Sarath June 28, 2017

Hi, 

We use crowd for user directory. And using scriptrunner we automate the users to be inactive if they haven't logged in last 90 days. So when the user turns to inactive is it possible to send them automated email notification that their account is inactive? 

1 answer

1 vote
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 28, 2017

Hi Sarath, 

So we use something similar. Below there are two functions, the one that sends the email I think is what you are looking for. 

// deactivate the given user
def deactivateUser(ApplicationUser user) { def userService = ComponentAccessor.getComponent(UserService) def updateUser = userService.newUserBuilder(user).active(false).build() def updateUserValidationResult = userService.validateUpdateUser(updateUser) if (updateUserValidationResult.isValid()) { userService.updateUser(updateUserValidationResult) log.info "${updateUser.name} deactivated" sendEmail(user.emailAddress) } else { log.error "Update of ${user.name} failed. ${updateUserValidationResult.getErrorCollection()}" } }
// send an email to the given address def sendEmail(String emailAddress) { SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer() if (mailServer) { Email email = new Email(emailAddress) email.setSubject("User Deactivated") email.setBody("You became inactive, please send us an email to make you active again, or something similar") mailServer.send(email) log.debug("Mail sent") } else { log.warn("There was an issue with the mail Server") } }

Hope that helps

kind regards, Thanos

Suggest an answer

Log in or Sign up to answer