0 votes
18 views
ago by (30.6k points)
Where is the mail server configured for BAW on WAS and on CP4BA, how do I send e-mails from a service (HTML, attachments), and how do task notification e-mails get enabled?

1 Answer

0 votes
ago by (30.6k points)

Three parts: platform configuration, sending from services, and the built-in notifications.

  • Configuration on WAS: the <email> section of 100Custom.xml (never 99Local.xml) sets the SMTP server and sender; restart the JVM afterwards:
<properties>
  <server merge="mergeChildren">
    <email merge="mergeChildren">
      <smtp-server merge="replace">smtp.example.com</smtp-server>
      <valid-from-required merge="replace">false</valid-from-required>
      <default-from-address merge="replace">baw@example.com</default-from-address>
      <send-external-email merge="replace">true</send-external-email>
    </email>
  </server>
</properties>
  • Configuration on CP4BA: the same settings live in the Workflow custom resource (the mail / SMTP parameters of the baw_configuration entry, with a secret for credentials) and the operator writes them into the container's configuration; a change triggers a rolling restart of the Workflow pods. Check the CR reference of your release for the exact parameter names.
  • Sending from a service: on traditional BAW the System Data toolkit's Send E-mail via SMTP integration service (to, from, subject, HTML body, attachments) uses the configuration above. On containers the "TC" variant of the System Data toolkit no longer contains it, so use a JavaMail script or an external mail API:
// server script sending HTML mail with JavaMail (works on WAS and Liberty); host and sender from environment variables
var props = new Packages.java.util.Properties();
props.put("mail.smtp.host", tw.env.smtpHost); props.put("mail.smtp.port", tw.env.smtpPort); props.put("mail.smtp.starttls.enable", "true");
var session = Packages.javax.mail.Session.getInstance(props);
var msg = new Packages.javax.mail.internet.MimeMessage(session);
msg.setFrom(new Packages.javax.mail.internet.InternetAddress(tw.env.mailFrom));
msg.setRecipients(Packages.javax.mail.Message.RecipientType.TO, Packages.javax.mail.internet.InternetAddress.parse(tw.local.to));
msg.setSubject(tw.local.subject, "UTF-8");
var body = new Packages.javax.mail.internet.MimeBodyPart(); body.setContent(tw.local.htmlBody, "text/html; charset=UTF-8");
var mp = new Packages.javax.mail.internet.MimeMultipart(); mp.addBodyPart(body);
if (tw.local.pdfBytes != null) {                                             // attachment from a document / report
  var att = new Packages.javax.mail.internet.MimeBodyPart();
  att.setDataHandler(new Packages.javax.activation.DataHandler(new Packages.javax.mail.util.ByteArrayDataSource(tw.local.pdfBytes, "application/pdf")));
  att.setFileName("order.pdf"); mp.addBodyPart(att);
}
msg.setContent(mp);
if (tw.env.smtpUser) Packages.javax.mail.Transport.send(msg, tw.env.smtpUser, tw.env.smtpPassword); else Packages.javax.mail.Transport.send(msg);

Built-in notifications (task assigned, due): each user enables them in Process Portal preferences (an administrator can set the preference for users through the user attributes); they use the SMTP configuration above, and the links in the messages use the server's configured external URL - set it correctly behind proxies or the links point at internal hosts. On CP4BA, Workplace notifications follow the same platform SMTP settings.

References

Related questions

723 questions

807 answers

98 comments

4.8k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...