Java Email at

Electronic mail is a method of exchanging messages between people using electronic devices. In this post, we’ll explain how to send an email message with Java through
By default, only the master environment can send emails. For non-master environments, you can configure outgoing emails via the management console.
Emails from are sent via a SendGrid-based SMTP proxy. Each project is provisioned as a SendGrid sub-account. These SendGrid sub-accounts are capped at 12k emails per month.

Below the sample code that uses Java Mail:

import sh.platform.config.Config;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class JavaEmailSender {

    private static final Logger LOGGER = Logger.getLogger(JavaEmailSender.class.getName());

    public void send() {
        Config config = new Config();
        String to = "";//change accordingly
        String from = "";//change accordingly
        String host = config.getSmtpHost();
        //or IP address
        //Get the session object
        Properties properties = System.getProperties();
        properties.setProperty("", host);
        Session session = Session.getDefaultInstance(properties);

        //compose the message
        try {
            MimeMessage message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
            message.setText("Hello, this is example of sending email  ");

            // Send message
            System.out.println("message sent successfully....");

        } catch (MessagingException exp) {
            LOGGER.log(Level.SEVERE, "there is an error to send an message", exp);

There is plenty of additional l documentation about using JavaMail, like this one, that shows how to send email with HTML format and an attachment: