Layer7 API Management

 View Only
  • 1.  How to send email from LAC?

    Posted Oct 12, 2017 09:05 AM

    If I am using LAC APIs as user registration endpoint for my application, after user registration I want to send an email confirmation email to user email. How would it be possible in LAC? do I need to write Java code to achieve this?

  • 2.  Re: How to send email from LAC?
    Best Answer

    Broadcom Employee
    Posted Oct 13, 2017 01:36 PM

    You can send email anywhere in LAC where you can write code. A typical place would be as an event on insert, say if you insert a record for a user registration. You will of course need an email server to communicate with, or some sort of email service like Amazon Simple Email Service. If you're just using SMTP, you might consider using Apache Commons Email, which makes it easy. Just add the jar to your classpath (e.g. lib directory for Tomcat), and you can send an email with:


    var SimpleEmail = Java.type("org.apache.commons.mail.SimpleEmail");
    var email = new SimpleEmail();
    email.setHostName(""); // Your SMTP server

    email.setSubject("Test Mail");
    email.setMsg("This is a test mail ... :-)");


    Full documentation is here:  

  • 3.  Re: How to send email from LAC?

    Posted Oct 13, 2017 02:11 PM

    Thank you so much! I will try this.

  • 4.  Re: How to send email from LAC?

    Posted Oct 23, 2017 01:53 AM

    I have installed LAC on Amazon Elastic Beanstalks, do you know how to add related jars into it?

  • 5.  Re: How to send email from LAC?

    Broadcom Employee
    Posted Oct 23, 2017 05:02 PM

    Two ways:


    1 - Add the jars to the Live API Creator war file (in the WEB-INF/lib directory). This can be done using the jar command.

    2 - Add the jars to the container's classpath by modifying the war file's .ebextensions.

  • 6.  Re: How to send email from LAC?

    Posted Oct 24, 2017 03:15 AM

    Thanks @taram, I did try these two ways yesterday with my own. #1 didn't work it may be due to the incorrect jar I was using. I had gone with #2 that seems to be working but still facing some other issues that require some other dependencies needs to be installed which are related to tomcat environment.


    Thanks for your reply and suggesting the appropriate ways to do this.