Send e-mail

One can send an e-mail from a strategy by using the JFUtils.sendMail method, which has text size and send frequency restrictions. This method allows one to send an e-mail in Remote Run mode.

Note: Available with JForex-API 2.9.10.

        JFUtils utils = context.getUtils();

        try {
             Future<IEmailResponse> future = utils.sendMail("[email protected]", "subject", "text");
             console.getOut().println("Waiting on response");
             IEmailResponse response = future.get(30, TimeUnit.SECONDS);
             if (response.isError()) {
             } else {
                 console.getOut().println("e-mail successfully sent!");
         } catch (Exception e) {

In order to send e-mails without the aforementioned restrictions, one can use the java mail library. The following strategy sends e-mail from the [email protected] to the specified recipient.

public class TestMail implements IStrategy {

    @Configurable("Recipient mail")
    public String mailAddress = "[email protected]";
    @Configurable("SMTP Server")
    public String smtpServer = "";
    private IConsole console;

    public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
        try {
            sendMail("[email protected]", mailAddress, "Hello 2", "Test mail \n Bye.");
        } catch (Exception e) {
            console.getErr().println("Failed to send email: " + e);
        console.getOut().println("No exception -> check the e-mail!");

    public boolean sendMail(String from, String to, String subj, String text) throws Exception {
        Properties props = new Properties();
        props.setProperty("", smtpServer);
        Session session = Session.getInstance(props);
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(from));
        msg.setRecipient(RecipientType.TO, new InternetAddress(to));
        return true;

The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.