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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

694 views 6 13
Read article

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