Sending sms via Java [closed]

1

Personally, I'm developing a financial application that I was asked to complete at the end of a posting, sending a sms to the primary admin. I am using Java web, Mavem, jsf, Hibernate. Could someone give me a light. Thank you.

    
asked by anonymous 12.10.2016 / 00:07

1 answer

1

Looking here for Google, I found this implementation here:

package br.com.meupackage;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
public class MailService {
    private final static String userAuthentication = "[email protected]";
    private final static String passwordUserAuthentication = "123456";
    private final static String sender = "[email protected]";
    private final static String smtp = "smtp.gmail.com";
    private final static boolean authentication = true;
    public static void sendMail(String message, String subject, String receiver)
            throws EmailException {
        SimpleEmail email = new SimpleEmail();
        email.setHostName(smtp);
        email.setAuthentication(userAuthentication, passwordUserAuthentication);
        email.setSSL(authentication);
        email.addTo(receiver);
        email.setCharset("UTF-8")
        email.setFrom(sender);
        email.setSubject(subject);
        email.setMsg(message);
        email.send();
        email = null;
    }
}

It is necessary to add in the pom.xml dependency of the Apache Commons Email

Source: link

    
12.10.2016 / 00:49