List of usage examples for org.apache.commons.mail DefaultAuthenticator DefaultAuthenticator
public DefaultAuthenticator(final String userName, final String password)
From source file:connection.EmailSending.java
public static void sendTextEmail(String subject, String content, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(MailInfor.HOST_NAME); email.setSmtpPort(465);// w w w . ja v a 2 s. co m email.setAuthenticator(new DefaultAuthenticator(MailInfor.EMAIL_SENDER, MailInfor.PASSWORD)); email.setSSLOnConnect(true); try { email.setFrom(MailInfor.EMAIL_SENDER); email.setSubject(subject); email.setMsg(content); email.addTo(recipientEmail); email.send(); } catch (EmailException ex) { Logger.getLogger(EmailSending.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:function.Email.java
public static void sendVerifyEmail(Customers customer, String hash) { try {//from ww w . j a va 2s .c o m HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(MY_EMAIL, MY_PASSWORD)); email.setSSLOnConnect(true); email.setFrom(MY_EMAIL); email.addTo(customer.getEmail()); email.setSubject("Xc nhn ti khon TiviStore"); email.setHtmlMsg("<html><h2>Cho " + customer.getCustomerName() + ",</h2>" + "<div><b>Vui lng click vo <a href='http://localhost:8084/ThuongMaiDienTu/Verify?u=" + customer.getCustomerID() + "&hash=" + hash + "'>y</a> xc nhn ti khon...</b></div><br />" + "<b>Cm n bn ng h!!!</b></div>" + "</html>"); email.setCharset("UTF-8"); email.setTextMsg("Trnh duyt khng h tr nh dng html!"); String a = email.send(); System.out.println(a); } catch (EmailException eex) { System.err.println(eex); } }
From source file:com.aprodher.actions.util.EmailUtils.java
public static Email conectaEmail() throws EmailException { Email email = new SimpleEmail(); email.setHostName(HOSTNAME);/*from ww w .j a va 2 s . c o m*/ email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator(USERNAME, PASSWORD)); email.setSSL(true); email.setTLS(true); email.setFrom(EMAILORIGEM); return email; }
From source file:controller.SendMailMachine.java
public static void sendMail(Cart cart, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(HOST_NAME);/*from w w w . j a va 2 s . c om*/ email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(EMAIL_SENDER, PASSWORD)); email.setSSLOnConnect(true); String subject = "Thng tin ha n"; String content = "\t\t\tTRUNG TM MUA SM BITTORRENT\n\nChi tit n hng ca bn: \n"; for (Map.Entry<Integer, Item> entrySet : cart.getCartItem().entrySet()) { Item item = entrySet.getValue(); content += item.getWatch().getName() + "\t\t\t\t\t\t" + item.getQuantity() + " x " + ((int) item.getWatch().getPrice()) + "000 VND\n"; } content += "Tng ha n: " + ((int) cart.sumPrice()) + "000 VND"; try { email.setFrom(EMAIL_SENDER); email.setCharset("UTF-8"); email.setSubject(subject); email.setMsg(content); email.addTo(recipientEmail); email.send(); } catch (EmailException ex) { ex.printStackTrace(); } }
From source file:com.sigaf.bean.MailReset.java
public static HtmlEmail conectaEmail() throws EmailException { HtmlEmail email = new HtmlEmail(); email.setHostName(HOSTNAME);//from w w w .j a v a2 s . com email.setSmtpPort(587); email.setSSL(true); email.setAuthenticator(new DefaultAuthenticator(USERNAME, PASSWORD)); email.setTLS(true); email.setFrom(EMAILORIGEM); return email; }
From source file:io.jhonesdeveloper.swing.util.EmailUtil.java
public static void sendBasicText(String hostName, String username, String password, String from, String subject, String msg, String[] to) throws EmailException { Email email = new SimpleEmail(); email.setHostName(hostName);//w w w . j a va2 s . c om email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(username, password)); email.setSSLOnConnect(true); email.setFrom(from); email.setSubject(subject); email.setMsg(msg); email.addTo(to); email.send(); }
From source file:model.Email.java
public static void sendConfirmation(String receiver, String token, PersonalAccount account) throws EmailException { SimpleEmail email = new SimpleEmail(); String message = "Sua conta foi criada com sucesso, porm ainda est inativa.\n"; message += "Nmero da conta: " + account.getNumber() + "\n"; message += "Agncia: " + account.getAgency().getNumber() + "\n"; message += "Token de autentificao: " + token + "\n"; message += "Com este token voc capaz de definir uma senha para sua conta para, ento, utiliz-la.\n"; message += "\nCaso voc perca este token, entre novamente com as informaes para abrir conta,"; message += " e um novo token ser gerado e reenviado voc."; try {//from w ww . j ava 2 s . c o m email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator("totheworldgroup@gmail.com", "albrcalu")); email.setSSLOnConnect(true); email.setFrom("totheworldgroup@gmail.com"); email.setSubject("Token de autentificao"); email.setMsg(message); email.addTo(receiver); email.send(); } catch (EmailException e) { System.out.println(e.getMessage()); } }
From source file:at.tugraz.kmi.medokyservice.ErrorLogNotifier.java
public static void errorEmail(String msg) { Email email = new SimpleEmail(); email.setHostName("something.com"); email.setSmtpPort(465);/* w ww.j av a2 s.c om*/ DefaultAuthenticator auth = new DefaultAuthenticator("username", "pwd"); email.setAuthenticator(auth); email.setSSLOnConnect(true); try { email.setFrom("email address"); email.setSubject("[MEDoKyService] Error"); email.setMsg(msg); email.addTo("yourmail.com"); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
From source file:com.github.somi92.seecsk.util.email.EmailSender.java
public static void sendEmail(EmailContainer ec) throws RuntimeException { try {/*from www .j a v a 2 s.co m*/ String user = Config.vratiInstancu().vratiVrednost(Constants.OrgInfoConfigKeys.ORGANISATION_EMAIL); String password = Config.vratiInstancu() .vratiVrednost(Constants.OrgInfoConfigKeys.ORGANISATION_EMAIL_PASSWORD); EmailAttachment ea = new EmailAttachment(); ea.setPath(ec.getAttachmentPath()); ea.setDisposition(EmailAttachment.ATTACHMENT); ea.setDescription("Primer ispravno popunjene uplatnice za ?lanarinu"); ea.setName("uplatnica.pdf"); MultiPartEmail mpe = new MultiPartEmail(); mpe.setDebug(true); mpe.setAuthenticator(new DefaultAuthenticator(user, password)); mpe.setHostName( Config.vratiInstancu().vratiVrednost(Constants.EmailServerConfigKeys.EMAIL_SERVER_HOST)); mpe.setSSLOnConnect(true); mpe.setStartTLSEnabled(true); mpe.setSslSmtpPort( Config.vratiInstancu().vratiVrednost(Constants.EmailServerConfigKeys.EMAIL_SERVER_PORT)); mpe.setSubject(ec.getSubject()); mpe.setFrom(ec.getFromEmail(), Config.vratiInstancu().vratiVrednost(Constants.OrgInfoConfigKeys.ORGANISATION_NAME)); mpe.setMsg(ec.getMessage()); mpe.addTo(ec.getToEmail()); mpe.attach(ea); mpe.send(); } catch (EmailException ex) { ex.printStackTrace(); throw new RuntimeException("Sistem nije uspeo da poalje email. Pokuajte ponovo."); } }
From source file:br.com.dedoduro.util.EnviarEmail.java
/** * Enviar o email para a lista de usarios especificados * @param emails/*ww w. j a v a2s .c o m*/ * @param assunto * @param conteudo */ private static void tratarEnvio(ArrayList<String> emails, String assunto, String conteudo) { HtmlEmail email = new HtmlEmail(); try { email.setHostName(Constantes.HOST_NAME_GMAIL); email.addTo(Constantes.ADMINISTRADOR_1); email.setFrom(Constantes.EMAIL_REMETENTE_GMAIL, "Administrador"); for (String tmp : emails) { email.addBcc(tmp); } email.setSubject(assunto); // Trabalhando com imagem... // URL url = new URL ("http://<ENDERECO DA IMAGEM AQUI...>"); // String idImg = email.embed(url, "logo"); email.setHtmlMsg(conteudo); // Tratando mensagem alternativa email.setTextMsg("Seu servidor de e-mail no suporta mensagem HTML... :-("); email.setSmtpPort(Constantes.PORTA_SMTP_GMAIL); email.setAuthenticator( new DefaultAuthenticator(Constantes.EMAIL_REMETENTE_GMAIL, Constantes.SENHA_REMETENTE_GMAIL)); email.setSSLOnConnect(true); // Enviando email email.send(); } catch (EmailException e) { e.printStackTrace(); } }