How to Send mail using gmail with Talend

This is a very common requirement by every talend user when it is required to send mail in different scenarios. These scenarios are

  • Successful completion of a job
  • Failure of job or subjobs
  • On particular event or based on¬†condition or specific variable value

In order to send mail, mail server details are required. It may be possible that the client may provide server details, but often they are not provided. In this case, you can create an account on gmail with specific user name like etl_info@gmail.com. To send mail using gmail, talend consists of a component tSendMail.

Following settings are required inside tSendMail component to send mail using newly created gmail account. They are as follows

SMTP Host – “smtp.gmail.com”

SMTP Port – 465

SSL Support – Enabled

Need authentication – Enabled

username – “newusername@gmail.com”

password – “yourpassword”

Use above settings to send mail using your gmail account.

Conditional mail Sending

When you want to send mail when particular condition arises after completion of your subjob, then you can connect tSendMail component using if clause and fill the condition variable with required condition say

context.variable >= 10

When you want to send mail when failure of particular subjob, then connect the subjob to tSendMail component and use system variable for that subjob where value is 1. Condition could be

((Integer)globalMap.get(“tRunJob_1_CHILD_RETURN_CODE”)) ==1

When you want to send mail on success, then connect another tSendMail component with following condition

((Integer)globalMap.get(“tRunJob_1_CHILD_RETURN_CODE”)) == 0

 

Vaibhav Waghmare

Helical IT Solutions

Leave a Reply