24 Şubat 2019 Pazar

SimpleEmail Sınıfı

Giriş
Şus atırı dahil ederiz.
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
constructor
Şöyle yaparız.
 Email email = new SimpleEmail();
send metodu
Şöyle yaparız.
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setSSLOnConnect(true);
email.setFrom("ross.donohoe@tvgmedia.com");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("foo@bar.com");
email.send();

Hiç yorum yok:

Yorum Gönder