List of usage examples for org.apache.commons.mail Email setBounceAddress
public Email setBounceAddress(final String email)
From source file:iddb.core.util.MailManager.java
private void setEmailProps(Email email) throws EmailException { email.setFrom(props.getProperty("from"), "IPDB"); if (props.containsKey("bounce")) email.setBounceAddress(props.getProperty("bounce")); if (props.containsKey("host")) email.setHostName(props.getProperty("host")); if (props.containsKey("port")) email.setSmtpPort(Integer.parseInt(props.getProperty("port"))); if (props.containsKey("username")) email.setAuthenticator(//from ww w . ja v a 2 s . c o m new DefaultAuthenticator(props.getProperty("username"), props.getProperty("password"))); if (props.containsKey("ssl") && props.getProperty("ssl").equalsIgnoreCase("true")) email.setSSL(true); if (props.containsKey("tls") && props.getProperty("tls").equalsIgnoreCase("true")) email.setTLS(true); if (props.containsKey("debug") && props.getProperty("debug").equalsIgnoreCase("true")) email.setDebug(true); }
From source file:com.music.service.EmailService.java
private Email createEmail(boolean html) { Email e = null; if (html) {// w ww.j a va2s . c om e = new HtmlEmail(); } else { e = new SimpleEmail(); } e.setHostName(smtpHost); if (!StringUtils.isEmpty(smtpUser)) { e.setAuthentication(smtpUser, smtpPassword); } if (!StringUtils.isEmpty(smtpBounceEmail)) { e.setBounceAddress(smtpBounceEmail); } e.setTLS(true); e.setSmtpPort(587); //tls port e.setCharset("UTF8"); //e.setDebug(true); return e; }
From source file:org.pepstock.jem.notify.engine.EmailNotifier.java
/** * This method sends an <code>Email</code>. <br> * It sets in the parameter <code>Email</code> the properties of the * parameter <code>JemEmail</code>: From User Email Address, From User Name, * subject, text, email destination addresses. <br> * It sets in the parameter <code>Email</code> the Email Server property and * the optional <code>SMTP</code> port, the properties that indicates if it * must use <code>SSL</code> and <code>TLS</code> protocol, the useirid and * password for <code>SMTP</code> server authentication if needed, the * optional bounce address, the subject, the text, and the recipients of the * email./*from w w w . j ava 2 s .co m*/ * * @param email the <code>JemEmail</code> with the properties of the email * to be sent. * @param sendingEmail the real <code>Email</code> that will be sent. * @see JemEmail * @see Email * @throws SendMailException if an error occurs. */ private void sendEmail(JemEmail email, Email sendingEmail) throws SendMailException { try { sendingEmail.setHostName(this.emailServer); if (this.smtpPort != NO_SMTP_PORT) { sendingEmail.setSmtpPort(this.smtpPort); } sendingEmail.setFrom(email.getFromUserEmailAddress(), email.getFromUserName()); if (email.hasSubject()) { sendingEmail.setSubject(email.getSubject()); } else { // log no subject LogAppl.getInstance().emit(NotifyMessage.JEMN014W, "Subject"); } if (email.hasText()) { sendingEmail.setMsg(email.getText()); } else { // log no text message LogAppl.getInstance().emit(NotifyMessage.JEMN014W, "Text Message"); } sendingEmail.setTo(email.getAllToEmailAddresses()); if (null != this.bounceAddress) { sendingEmail.setBounceAddress(this.bounceAddress); } sendingEmail.setSentDate(new Date()); sendingEmail.setSSL(this.isSSL); sendingEmail.setTLS(this.isTLS); if (null != this.authenticationUserId && null != this.authenticationPassword) { sendingEmail.setAuthenticator( new DefaultAuthenticator(this.authenticationUserId, this.authenticationPassword)); } sendingEmail.send(); LogAppl.getInstance().emit(NotifyMessage.JEMN015I, email); } catch (EmailException eEx) { LogAppl.getInstance().emit(NotifyMessage.JEMN016E, eEx, email); throw new SendMailException(NotifyMessage.JEMN016E.toMessage().getFormattedMessage(email), eEx); } }
From source file:org.structr.common.MailHelper.java
private static void setup(final Email mail, final String to, final String toName, final String from, final String fromName, final String cc, final String bcc, final String bounce, final String subject) throws EmailException { // FIXME: this might be slow if the config file is read each time final Properties config = Services.getInstance().getCurrentConfig(); final String smtpHost = config.getProperty(Services.SMTP_HOST, "localhost"); final String smtpPort = config.getProperty(Services.SMTP_PORT, "25"); final String smtpUser = config.getProperty(Services.SMTP_USER); final String smtpPassword = config.getProperty(Services.SMTP_PASSWORD); final String smtpUseTLS = config.getProperty(Services.SMTP_USE_TLS, "true"); final String smtpRequireTLS = config.getProperty(Services.SMTP_REQUIRE_TLS, "false"); mail.setCharset(charset);/*from w ww .ja va2 s .c o m*/ mail.setHostName(smtpHost); mail.setSmtpPort(Integer.parseInt(smtpPort)); mail.setStartTLSEnabled(Boolean.parseBoolean(smtpUseTLS)); mail.setStartTLSRequired(Boolean.parseBoolean(smtpRequireTLS)); mail.setCharset(charset); mail.setHostName(smtpHost); mail.setSmtpPort(Integer.parseInt(smtpPort)); if (StringUtils.isNotBlank(smtpUser) && StringUtils.isNotBlank(smtpPassword)) { mail.setAuthentication(smtpUser, smtpPassword); } mail.addTo(to, toName); mail.setFrom(from, fromName); if (StringUtils.isNotBlank(cc)) { mail.addCc(cc); } if (StringUtils.isNotBlank(bcc)) { mail.addBcc(bcc); } if (StringUtils.isNotBlank(bounce)) { mail.setBounceAddress(bounce); } mail.setSubject(subject); }