List of usage examples for org.apache.commons.mail Email setFrom
public Email setFrom(final String email, final String name) throws EmailException
From source file:com.moss.error_reporting.server.Notifier.java
private void prepEmail(Email email, ReportId id) throws EmailException { email.setHostName(smtpServer);//from w w w . j av a 2s.co m for (String recipient : emailRecipients) { email.addTo(recipient); } // email.addTo(emailRecipients.get(0)); email.setFrom(emailFromAddress, "Error Report Server"); email.setSubject("Error Report Received: " + id.getUuid()); }
From source file:com.basetechnology.s0.agentserver.mail.AgentMail.java
public int sendMessage(User user, String toEmail, String toName, String subject, String message, String messageTrailer1, String messageTrailer2) throws AgentServerException { try {/*from ww w . j a v a2 s. c om*/ // Wait until we have mail access agentServer.mailAccessManager.wait(user, toEmail); int messageId = ++nextMessageId; log.info("Sending mail on behalf of user " + user.id + " with message Id " + messageId + " To: '<" + toName + ">" + toEmail + "' Subject: '" + subject + "'"); Email email = new SimpleEmail(); email.setDebug(debug); email.setHostName(mailServerHostName); email.setSmtpPort(mailServerPort); email.setAuthenticator(new DefaultAuthenticator(mailServerUserName, mailServerUserPassword)); email.setTLS(true); email.setFrom(mailServerFromEmail, mailServerFromName); // TODO: Reconsider whether we want to always mess with subject line email.setSubject(subject + " (#" + messageId + ")"); email.setMsg(message + messageTrailer1 + (messageTrailer2 != null ? messageId + messageTrailer2 : "")); email.addTo(toEmail, toName); email.send(); log.info("Message sent"); // Return the message Id return messageId; } catch (EmailException e) { e.printStackTrace(); throw new AgentServerException("EmailException sending email - " + e.getMessage()); } }
From source file:gov.nih.nci.firebird.service.messages.email.EmailServiceImpl.java
private void initEmailInfo(Email email) throws EmailException { email.setMailSession(mailSession);//from ww w . ja va 2 s . c om String smtpPort = email.getMailSession().getProperty(Email.MAIL_PORT); email.setFrom(senderEmail, senderName); if (StringUtils.isNumeric(smtpPort) && Integer.valueOf(smtpPort) > 0) { email.setSmtpPort(Integer.valueOf(smtpPort)); } }
From source file:edu.corgi.uco.sendEmails.java
public void sendConfirmation(String email2, String firstName, String lastName, int token, int id) throws EmailException { Email email = new SimpleEmail(); email.setDebug(true);//from w ww . j a v a2 s.c o m email.setHostName("smtp.gmail.com"); email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung")); email.setStartTLSEnabled(true); email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO CS Corgi"); email.setSubject("Account Confirmation"); email.setMsg(firstName + " " + lastName + " please go to the following address http://localhost:8080/Corgi/faces/accountAuth.xhtml " + "and enter the token:" + token + " and the ID:" + id + " to confirm and activate your account"); System.out.print("Email Address: " + email2); email.addTo(email2); email.send(); }
From source file:com.qwazr.connectors.EmailConnector.java
private void generic_params(Email email, Map<String, Object> params) throws EmailException { Object subject = params.get("subject"); if (subject != null) email.setSubject(subject.toString()); Object from_email = params.get("from_email"); if (from_email != null) { Object from_name = params.get("from_name"); if (from_name != null) email.setFrom(from_email.toString(), from_name.toString()); else/* w w w.j a va2s . c o m*/ email.setFrom(from_email.toString()); } }
From source file:com.qwazr.library.email.EmailConnector.java
private void generic_params(final Email email, final Map<String, Object> params) throws EmailException { Object subject = params.get(PARAM_SUBJECT); if (subject != null) email.setSubject(subject.toString()); Object from_email = params.get(PARAM_FROM_EMAIL); if (from_email != null) { Object from_name = params.get(PARAM_FROM_NAME); if (from_name != null) email.setFrom(from_email.toString(), from_name.toString()); else// w w w . j av a 2 s . com email.setFrom(from_email.toString()); } }
From source file:edu.corgi.uco.sendEmails.java
public String send(String emailAddress, String studentFirstName, String studentLastName) throws EmailException { System.out.print("hit send"); Email email = new SimpleEmail(); System.out.print("created email file"); email.setDebug(true);// w w w. j ava2 s . co m email.setHostName("smtp.gmail.com"); email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung")); email.setStartTLSEnabled(true); email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO CS Secretary"); email.setSubject("Advisement Update"); email.setMsg(studentFirstName + " " + studentLastName + " your advisment has been processed and the hold on your account will be removed shortly"); System.out.print("Email Address: " + emailAddress); email.addTo(emailAddress); System.out.print("added values"); email.send(); System.out.print("sent"); return null; }
From source file:com.adobe.acs.commons.email.impl.EmailServiceImpl.java
private Email getEmail(final MailTemplate mailTemplate, final Class<? extends Email> mailType, final Map<String, String> params) throws EmailException, MessagingException, IOException { final Email email = mailTemplate.getEmail(StrLookup.mapLookup(params), mailType); if (params.containsKey(EmailServiceConstants.SENDER_EMAIL_ADDRESS) && params.containsKey(EmailServiceConstants.SENDER_NAME)) { email.setFrom(params.get(EmailServiceConstants.SENDER_EMAIL_ADDRESS), params.get(EmailServiceConstants.SENDER_NAME)); } else if (params.containsKey(EmailServiceConstants.SENDER_EMAIL_ADDRESS)) { email.setFrom(params.get(EmailServiceConstants.SENDER_EMAIL_ADDRESS)); }/*ww w . j a v a 2s. c o m*/ if (connectTimeout > 0) { email.setSocketConnectionTimeout(connectTimeout); } if (soTimeout > 0) { email.setSocketTimeout(soTimeout); } // #1008 setting the subject via the setSubject(..) parameter. if (params.containsKey(EmailServiceConstants.SUBJECT)) { email.setSubject(params.get(EmailServiceConstants.SUBJECT)); } return email; }
From source file:fr.gael.dhus.messaging.mail.MailServer.java
public void send(Email email, String to, String cc, String bcc, String subject) throws EmailException { email.setHostName(getSmtpServer());/*www . j a v a 2 s .c o m*/ email.setSmtpPort(getPort()); if (getUsername() != null) { email.setAuthentication(getUsername(), getPassword()); } if (getFromMail() != null) { if (getFromName() != null) email.setFrom(getFromMail(), getFromName()); else email.setFrom(getFromMail()); } if (getReplyto() != null) { try { email.setReplyTo(ImmutableList.of(new InternetAddress(getReplyto()))); } catch (AddressException e) { logger.error("Cannot configure Reply-to (" + getReplyto() + ") into the mail: " + e.getMessage()); } } // Message configuration email.setSubject("[" + cfgManager.getNameConfiguration().getShortName() + "] " + subject); email.addTo(to); // Add CCed if (cc != null) { email.addCc(cc); } // Add BCCed if (bcc != null) { email.addBcc(bcc); } email.setStartTLSEnabled(isTls()); try { email.send(); } catch (EmailException e) { logger.error("Cannot send email: " + e.getMessage()); throw e; } }
From source file:com.waveerp.sendMail.java
public void sendMsg(String strSource, String strSourceDesc, String strSubject, String strMsg, String strDestination, String strDestDesc) throws Exception { // Call the registry management system registrySystem rs = new registrySystem(); // Call the encryption management system desEncryption de = new desEncryption(); de.Encrypter("", ""); String strHost = rs.readRegistry("NA", "NA", "NA", "EMAILHOST"); String strPort = rs.readRegistry("NA", "NA", "NA", "EMAILPORT"); String strUser = rs.readRegistry("NA", "NA", "NA", "EMAILUSER"); String strPass = rs.readRegistry("NA", "NA", "NA", "EMAILPASSWORD"); log(DEBUG, strHost + "|" + strPort + "|" + strUser + "|" + strPass); //Decrypt the encrypted password. strPass = de.decrypt(strPass);//from w ww .j a va 2s . c o m Email email = new SimpleEmail(); email.setHostName(strHost); email.setSmtpPort(Integer.parseInt(strPort)); email.setAuthenticator(new DefaultAuthenticator(strUser, strPass)); email.setTLS(false); email.setFrom(strSource, strSourceDesc); email.setSubject(strSubject); email.setMsg(strMsg); email.addTo(strDestination, strDestDesc); email.send(); }