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 Tuesday in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

45 views 0 2
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