1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
package resourcestore.applycontent;
import org.apache.commons.mail.DefaultAuthenticator; import org.apache.commons.mail.Email; import org.apache.commons.mail.EmailException; import org.apache.commons.mail.SimpleEmail;
public class SendMail {
public static void send() throws EmailException { Email email = new SimpleEmail(); email.setHostName("10.106.128.254"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator("name", "password")); email.setSSLOnConnect(true); email.setFrom("[email protected]"); email.setSubject("TestMail"); email.setMsg("This is a test mail ... :-)"); email.addTo("[email protected]"); email.send(); } }
|
近期评论