Creating and Configuring Email Alert Gateways 
Alerting gateways specify the addressee as well as the content of the message that is to be sent to the operator. You can have more than one email gateway, if you want to use multiple SMTP servers. When you configure multiple alert gateways, you must pay attention to the pattern you use as well as the processing order of each email gateway. The most specific address patterns have to have the lowest processing order, or you might have the wrong email gateway being used. For example, an email gateway with an Address Pattern of *masalan.com and a processing order of 1 will take precedence over any other email gateway for masalan.com, like de.masalan.com or us.masalan.com if their processing order is greater than 1. SAP recommends using a catch-all gateway with an extremely high processing order, like 99, to make sure all emails are sent.
Email alert gateway actions allow you to customize the email and perform specific tasks before it is sent using RedwoodScript. You can, for example, cancel it under specific circumstances.
Setting up email
Navigate to .
Choose Submit from the context menu of System_Mail_Configure.
Specify only the from address if you do not know the address of the SMTP server. This will attempt to detect the appropriate mail server to use automatically.
Check the status of the job in .
If the job ends in status Completed then the mail server has successfully been detected and stored.
If the job ends in status Error, the mail server could not be automatically detected. You should look at the log file for more information. You can re-run the job and specify the mail server to use. You should ask your system or network administrator for the name or IP address of your SMTP mail server.
Creating an email gateway
Navigate to .
Choose New from the context menu.
Fill in the fields Name, Address Pattern and Processing Order.
Optionally set custom headers on the Headers and specify files to attach on the Job File Attachments tab.
Choose Save & Close.
Creating an email gateway for masalan.com
Navigate to .
Choose New from the context menu.
Fill in the fields Name, fill *@masalan.com into the Address Pattern and 99 into Processing Order.
On the Headers tab, choose New and fill From into the Name field and prd-operators@masalan.com into the Value field.
On the Headers tab, choose New and fill subject into the Name field and prd-Job ${topLevelJobId} failed: ${subject}
On the Job File Attachments tab choose New, enter stderr into the Name field, choose New again and enter stdout into the Name field.
Choose Save & Close.
You want to wait until the second run of the job has failed before you send alerting emails, this is done by suppressing the first email and operator message in the alert gateway action:
{
// Get the alert information
Alert alert = jcsEmailAlertGatewayPreSendActionContext.getAlert();
OperatorMessage om = alert.getOperatorMessage();
SchedulerEntity se = om.getSenderObject();
// Do not send emails for the first failure
if (se instanceof Job)
{
Job j = (Job) se;
// If RestartJobId is null, then this is the first job.
if (j.getStatus().getState() == JobStatusState.Final && null == j.getRestartJobId())
{
// Suppress sending the email
jcsEmailAlertGatewayPreSendActionContext.setSend(false);
// Reply to and delete the operator message
om.setReply("Acknowledge");
om.deleteObject();
}
}
}