Friday, May 20, 2016

apache commons-email SimpleEmail sent out email missed subject line

following code is simple and use to send out email, but in my case, received email miss subject line, the problem is the class path include som libraries that cause java-mail to fail

public class Test{
        public static void main(String[] args){
                try{
                SimpleEmail email = new SimpleEmail();
                email.setDebug(true);
                email.setHostName("xx.xxx.xxx.xxx");
                email.setSmtpPort(25);
                email.setSSLOnConnect(false);
                email.setFrom("noreply@openlane.com");
                email.setSubject("THIS IS SUBJECT LINE");
                email.setMsg("This is a test mail from command line");
                email.addTo("my.email@openlane.com");
                email.send();
                }catch(Exception e){
                        e.printStackTrace();
                }
        }
}

the problam library is geronimo.specs:geronimo.specs and geronimo-activation_1.1_spec:
org.apache.geronimo.specs
exclude them from pom file(or classpath will solve the problem)

No comments:

Post a Comment