Example scripts
To homepage
Confluence

Send email notification from a custom script in Confluence.
Created 9 month(s) ago, Updated 1 day(s) ago
App in script

ScriptRunner For Confluence
by Adaptavist
Compatibility

Confluence
Language |
groovy
import javax.mail.internet.*
import javax.mail.*
Properties prop = new Properties()
//Enter the details of your SMTP server
prop.put("mail.smtp.auth", true)
prop.put("mail.smtp.host", "smtp.gmail.com")
prop.put("mail.smtp.port", "450")
prop.put("mail.smtp.starttls.enable", "true")
String emailId = "<email id>"
String password = "<password>"
Session session = Session.getInstance(prop, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
new PasswordAuthentication(emailId, password)
}
})
MimeMessage msg = new MimeMessage(session)
msg.setFrom(new InternetAddress(emailId, "NoReply-JD"))
msg.setSubject("<Test email>", "UTF-8")
msg.setText("<Test body>", "UTF-8")
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailId, false))
Transport.send(msg)
logger.info("Email Sent Successfully!!")
Having an issue with this script?
Report it here