List of usage examples for org.apache.commons.mail Email send
public String send() throws EmailException
From source file:com.aprodher.actions.util.EmailUtils.java
public static void enviaEmail(Mensaje mensagem) throws EmailException { Email email = new SimpleEmail(); email = conectaEmail();// ww w. j av a 2 s .c om email.setSubject(mensagem.getTitulo()); email.setMsg(mensagem.getMensagem()); email.addTo(mensagem.getDestino()); String resposta = email.send(); JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("emailenviado") + resposta); }
From source file:gsn.utils.services.EmailService.java
/** * This method send a user configured email {@link org.apache.commons.mail.Email} after having updated the * email session from the property file. * * @param email/*from w w w . java 2s.c o m*/ * @return true if the email has been sent successfully, false otherwise. * @throws org.apache.commons.mail.EmailException * */ public static void sendCustomEmail(org.apache.commons.mail.Email email) throws EmailException { email.setMailSession(Session.getInstance(Utils.loadProperties(SMTP_FILE))); email.setDebug(true); email.send(); }
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 ww .j a va 2 s . c o m 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:br.fgv.util.EmailSender.java
public static void enviarEmail(String body, String subject) throws EmailException { StringBuffer sb = new StringBuffer(""); sb.append(body);//from w w w. j a v a 2 s. c om Email email = new SimpleEmail(); email.setHostName("smtp.gmail.com"); email.setDebug(true); email.setSSLOnConnect(true); email.addTo("wesley.seidel@gmail.com"); email.setAuthentication("wseidel.fgv", "batavinhofgv"); email.setFrom("wseidel.fgv@gmail.com"); email.setSubject(subject); email.setMsg(sb.toString()); email.send(); }
From source file:de.alpharogroup.message.system.service.CommonsEmailSendService.java
public static void sendEmail(final EmailConfiguration config, InfoMessageModel model) throws EmailException { // TODO make class for email config... Email email = new SimpleEmail(); email.setHostName(config.getHostName()); email.setSmtpPort(config.getSmtpPort()); email.setFrom(model.getApplicationSenderAddress()); email.setSubject(model.getMessageContentModel().getSubject()); email.setMsg(model.getMessageContentModel().getContent()); email.addTo(model.getRecipientEmailContact()); email.send(); }
From source file:com.reizes.shiva.net.mail.EmailSender.java
public static String sendMail(String host, int port, String from, String to, String subject, String text) throws IOException, EmailException { if (to != null && host != null) { String[] emailTo = StringUtils.split(to, ';'); Email email = new SimpleEmail(); email.setHostName(host);//from w w w. j av a 2 s . c om email.setSmtpPort(port); email.setFrom(from); for (String recv : emailTo) { email.addTo(recv); } email.setSubject(subject); email.setMsg(text); return email.send(); } return null; }
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);//from www . j a va 2s .c o m 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:de.knurt.fam.core.util.mail.UserMailSender.java
/** * send an email without need to put it into the userbox (without saved in * database). put only smtp port and host to it as configured in * {@link UserMailSender}. do not change anything else but send the email! * //w w w . jav a2 s . c o m * @param raw * all content (subject, msg, attachments, from, to) must be set * @return true if sending succeeded. */ public static boolean sendWithoutUserBox(Email raw) { boolean result = true; UserMailSender dse = getInstance(); raw.setHostName(dse.hostName); raw.setSmtpPort(dse.smtpPort); if (FamConnector.isDev() == false) { try { raw.send(); } catch (EmailException e) { result = false; FamLog.exception("sendWithoutUserBox: " + e.getMessage(), e, 201106131753l); } } if (result) { if (SEND_WITHOUT_METER == Integer.MAX_VALUE) { SEND_WITHOUT_METER = 0; } SEND_WITHOUT_METER++; } return result; }
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);//from w ww . ja va 2s. c om 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:de.maklerpoint.office.Schnittstellen.Email.SimpleEmailSender.java
/** * /*from w w w . j ava2 s . c o m*/ * @param adress * @param Subject * @param body * @throws EmailException */ public static void sendSimpleEMail(String adress, String Subject, String body) throws EmailException { Email email = new SimpleEmail(); email.setHostName(Config.get("mailHost", "")); email.setSmtpPort(Config.getConfigInt("emailPort", 25)); email.setTLS(Config.getConfigBoolean("mailTLS", false)); email.setSSL(Config.getConfigBoolean("mailSSL", false)); //email.setSslSmtpPort(Config.getConfigInt("emailPort", 25)); email.setAuthenticator( new DefaultAuthenticator(Config.get("mailUsername", ""), Config.get("mailPassword", ""))); email.setFrom(Config.get("mailSendermail", ""), Config.get("mailSender", "")); email.setSubject(Subject); email.setMsg(body); email.addTo(adress); email.send(); }