List of usage examples for org.apache.commons.mail Email setFrom
public Email setFrom(final String email) throws EmailException
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 www. jav a 2 s . c o m*/ }
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);/*w w w . j a v a 2s. c o m*/ 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: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);/*from ww w.java2 s. com*/ 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:com.aprodher.actions.util.EmailUtils.java
public static Email conectaEmail() throws EmailException { Email email = new SimpleEmail(); email.setHostName(HOSTNAME);/*from w w w. j a v a2 s . co m*/ email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator(USERNAME, PASSWORD)); email.setSSL(true); email.setTLS(true); email.setFrom(EMAILORIGEM); return email; }
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 o m 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: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.java2s.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: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 ww . j a v a2s . 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:model.EmailJava.java
public static void enviarEmail(String userEmail) { try {//from ww w . jav a 2 s .c o m 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); } }
From source file:gobblin.util.EmailUtils.java
/** * A general method for sending emails./*w w w. ja va2 s. com*/ * * @param state a {@link State} object containing configuration properties * @param subject email subject * @param message email message * @throws EmailException if there is anything wrong sending the email */ public static void sendEmail(State state, String subject, String message) throws EmailException { Email email = new SimpleEmail(); email.setHostName(state.getProp(ConfigurationKeys.EMAIL_HOST_KEY, ConfigurationKeys.DEFAULT_EMAIL_HOST)); if (state.contains(ConfigurationKeys.EMAIL_SMTP_PORT_KEY)) { email.setSmtpPort(state.getPropAsInt(ConfigurationKeys.EMAIL_SMTP_PORT_KEY)); } email.setFrom(state.getProp(ConfigurationKeys.EMAIL_FROM_KEY)); if (state.contains(ConfigurationKeys.EMAIL_USER_KEY) && state.contains(ConfigurationKeys.EMAIL_PASSWORD_KEY)) { email.setAuthentication(state.getProp(ConfigurationKeys.EMAIL_USER_KEY), PasswordManager .getInstance(state).readPassword(state.getProp(ConfigurationKeys.EMAIL_PASSWORD_KEY))); } Iterable<String> tos = Splitter.on(',').trimResults().omitEmptyStrings() .split(state.getProp(ConfigurationKeys.EMAIL_TOS_KEY)); for (String to : tos) { email.addTo(to); } String hostName; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { LOGGER.error("Failed to get the host name", uhe); hostName = "unknown"; } email.setSubject(subject); String fromHostLine = String.format("This email was sent from host: %s%n%n", hostName); email.setMsg(fromHostLine + message); email.send(); }
From source file:com.esofthead.mycollab.servlet.InstallUtils.java
public static void checkSMTPConfig(String host, int port, String username, String password, boolean auth, boolean isStartTls, boolean isSSL) { try {/*w w w. j a v a 2s . c om*/ Properties props = new Properties(); if (auth) { props.setProperty("mail.smtp.auth", "true"); } else { props.setProperty("mail.smtp.auth", "false"); } if (isStartTls) { props.setProperty("mail.smtp.starttls.enable", "true"); props.setProperty("mail.smtp.startssl.enable", "true"); } else if (isSSL) { props.setProperty("mail.smtp.startssl.enable", "false"); props.setProperty("mail.smtp.ssl.enable", "true"); props.setProperty("mail.smtp.ssl.socketFactory.fallback", "false"); } Email email = new SimpleEmail(); email.setHostName(host); email.setSmtpPort(port); email.setAuthenticator(new DefaultAuthenticator(username, password)); if (isStartTls) { email.setStartTLSEnabled(true); } else { email.setStartTLSEnabled(false); } if (isSSL) { email.setSSLOnConnect(true); } else { email.setSSLOnConnect(false); } email.setFrom(username); email.setSubject("MyCollab Test Email"); email.setMsg("This is a test mail ... :-)"); email.addTo(username); email.send(); } catch (Exception e) { throw new UserInvalidInputException(e); } }