Mail

Catalyst Mail enables you to add the email addresses of your business that will be used to send emails to the end-users from your Catalyst application. You can configure email addresses of public domains or of your organization's own domains. You can also use an external email client of your choice and configure its SMTP settings with Catalyst, instead of using the built-in Catalyst email client.

Send Mail

You must configure the domains, email addresses, and the SMTP settings for an email client of your choice from the console. The code snippet shown here enables you to send emails to the email addresses you specify from your Catalyst application.

Catalyst enables you to set multiple email addresses as the receivers, and to CC, BCC, and reply to through a single send mail operation. You can also attach files in your email. The maximum supported limits for email recipients and file attachments in a single send mail operation are specified below:

  • To address: 10
  • CC: 10
  • BCC: 5
  • Reply to: 5
  • Number of file attachments: 5
  • Size of file attachments: 15 MB (through a single file or multiple files upto 5 files)

Note: The subject, sender, and atleast one recipient email addresses are mandatory. Other attributes of the email are optional.

You must fetch an instance of ZCMailContent as shown in the code below. You can define the recipients and file attachments of an email as array lists. You must then set these lists, as well as the sender's email address, the subject and the content of the email in the ZCMailContent object, and pass it as an argument to the sendMail() method to send the email.

Note: You must have configured and verified the sender's email address in the Catalyst console to be able to send emails. If the sender's email is hosted on a private domain or if you choose to use a third-party email client, you must configure them before sending emails as well.

Ensure the following packages are imported:

Copiedimport com.zc.component.mail.ZCMail;
import com.zc.component.mail.ZCMailContent;
CopiedZCMailContent mailContent = ZCMailContent.getInstance(); //Get a ZCMailContent instance

ArrayList<String> toMailList = new ArrayList<String>(); //Add the recipient email addresses as an array list
toMailList.add("vanessa.hyde@zoho.com");
toMailList.add("r.owens@zoho.com");
toMailList.add("chang.lee@zoho.com");

ArrayList<String> ccMailList = new ArrayList<>(); //Add the email addresses to CC as an array list
ccMailList.add("p.boyle@zylker.com");
ccMailList.add("robert.plant@zylker.com");

ArrayList<String> bccMailList = new ArrayList<>(); //Add the email addresses to BCC as an array list
bccMailList.add("ham.gunn@zylker.com");
bccMailList.add("rover.jenkins@zylker.com");

ArrayList<String> replytoMailList = new ArrayList<>(); //Add the email addresses to reply to as an array list
replytoMailList.add("peter.d@zoho.com");
replytoMailList.add("arnold.h@zoho.com");

ArrayList<File> attachments = new ArrayList<>(); //Add the email attachments as an array list
File file1 = new File("kycform.pdf");
File file2 = new File("info.png");
attachments.add(file);

// Set the email properties in the ZCMailContent object
mailContent.setFromEmail("emma@zylker.com"); //Set the sender's email address
mailContent.setToEmailList(toMailList); //Pass the recipient array list
mailContent.setCcEmailList(ccMailList); //Pass the CC array list
mailContent.setBccEmailList(bccMailList); //Pass the BCC array list
mailContent.setReplyTo(replyToMailList); //Pass the reply to array list
mailContent.setSubject("Greetings from Zylker Corp!"); //Set the email's subject
mailContent.setHtmlMode(true); //Set the email's body as an HTML content
mailContent.setContent("<p>Hello,</p> We're glad to welcome you at Zylker Corp. To begin your journey with us, please download the attached KYC form and fill in your details. You can send us the completed form to this same email address.</p>We cannot wait to get started!<p><p>Cheers!</p><p>Team Zylker</p>"); //Set the email's body as an HTML content
mailContent.setAttachments(attachments); //Pass the email attachments array list

ZCMail.getInstance().sendMail(mailContent); //Send emails using the mailContent object