23.58
0
package agung.email;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
/**
* @author Agung Setiawan
*/
public class SendSimpleEmail {
    public static void main(String[] args) throws EmailException {
        SimpleEmail email = new SimpleEmail();
        /*** konfigurasi ***/
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        email.setAuthenticator(new DefaultAuthenticator("username", "password"));
        email.setSSLOnConnect(true);
        /*** Email pengirim ***/
        email.setFrom("blinkawan@gmail.com");
        /*** Email Tujuan ***/
        email.addTo("blink_boyz_26@yahoo.com");
        /*** Subjek Email ***/
        email.setSubject("Tes Kirim Email");
        /*** Isi Pesan ***/
        email.setMsg("Lagi Belajar Mengirim Email Lewat Java");
        /*** Mengirim Email ***/
        email.send();
    }
}

0 komentar:

Posting Komentar