Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package model; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.mail.DefaultAuthenticator; import org.apache.commons.mail.Email; import org.apache.commons.mail.EmailException; import org.apache.commons.mail.SimpleEmail; /** * * @author JoaoPedro */ public class EmailJava { public static void enviarEmail(String userEmail) { try { Email email = new SimpleEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); //email.setAuthenticator(new DefaultAuthenticator("username", "password")); email.setAuthentication("codbarzmgbr@gmail.com ", "streetworkout2014"); email.setSSLOnConnect(true); email.setFrom("jpmuniz88@gmail.com"); email.setSubject("CodbarZ"); email.setMsg("Junte-se ao CodbarZ. \n" + "Atleta junte-se ao nosso time, \n" + "empreendedores junte-se para nos apoiar, \n" + "Associe essa ideia, um projeto de inovado e aberto a todos que desejar evoluir com CodbarZ"); email.addTo(userEmail); email.send(); } catch (EmailException ex) { Logger.getLogger(EmailJava.class.getName()).log(Level.SEVERE, null, ex); } } /* public static void main(String[] args) { String email="jpmuniz209@hotmail.com"; enviarEmail(email); }*/ }