Using a Send email script

Last updated: Mar 12, 2025
Using a Send email script

You can notify recipients about events in pipelines by replacing email commands in your migrated flows with the sendmailWrapper script.

About this task

When you create a pipeline job, you can use the script /mnts/ds-storage/utilityScripts/sendMailWrapper.sh in the Bash script node. The script acts as the mail, mailx, and sendmail commands in your migrated jobs. Before you run a migrated job, you need to create a volume and a storage volume connection for ds-storage. The script is installed to the ds-storage persistent volume.

You can also use the sendMailWrapper script in the before-job and after-job subroutines. Use the /ds-storage/utilityScripts/sendMailWrapper.sh path for your script in the Shell command field. For more information on before/after job subroutines, see Setting up before-job and after-job subroutines in DataStage.

Procedure

  1. Add label to the persistent volume claim (PVC) to make it available for storage volume creation:
    oc label pvc datastage-ibm-datastage-ds-storage-pvc zen_storage_volume_include=true -n <namespace>
  2. Go to Administration > Storage Volumes.
  3. From the Existing VPC field, select and add the volume datastage-ibm-datastage-ds-storage-pvc.
  4. In the Volume name field, create a storage volume connection by selecting the volume ds-storage from your project, with /mnts/ds-storage in the Mount path field.
  5. In a Bash script, insert the command /mnts/ds-storage/utilityScripts/sendMailWrapper.sh to use the sendmailWrapper script.
    You can turn on all the DataStage® scripts to appear in the Bash Script Elements list. In the toolbar, select Manage default settings, go to the Pipeline settings tab, and select Enable DataStage activity.
    Note: You need to create the storage volume for the DataStage functions to appear automatically after typing ds- in the Inline script code.

Example

Example of the sendMailWrapper.sh command in a Bash script node:
UserVars_MailBody="mail body"
UserVars_MailSubject="mail subject"
UserVars_MailRecipient="abc@mail.com"
echo -e "${UserVars_MailBody}"  | /mnts/ds-storage/utilityScripts/sendMailWrapper.sh -s "${UserVars_MailSubject}" ${UserVars_MailRecipient}
echo -e "To: abc@ibm.com\nSubject: Test\nContent-Type: text/html\nMIME-Version: 1.0\n<html><body><pre><b>Test</b><br></pre></body></html>"| /mnts/ds-storage/utilityScripts/sendMailWrapper.sh -t
echo "test mail body" | /mnts/ds-storage/utilityScripts/sendMailWrapper.sh -v -s "Test Mail" abc@xxx.com
Example of the sendMailWrapper.sh command in a Shell command:
echo "mail body" | /ds-storage/utilityScripts/sendMailWrapper.sh -a /mnts/attachement1.txt -s "subject" support@ibm.com