Email notifications for inactive users Edited

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

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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,596 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you