/** * Add a reply to address to the email. The email * address will also be used as the personal name. * The name will be encoded by the charset of {@link #setCharset(java.lang.String) setCharset()}. * If it is not set, it will be encoded using * the Java platform's default charset (UTF-16) if it contains * non-ASCII characters; otherwise, it is used as is. * * @param email A String. * @return An Email. * @throws EmailException Indicates an invalid email address * @since 1.0 */ public Email addReplyTo(final String email) throws EmailException { return this.addReplyTo(email, null); }
/** * Add a reply to address to the email using the specified address and * the specified personal name. * The name will be encoded by the charset of {@link #setCharset(java.lang.String) setCharset()}. * If it is not set, it will be encoded using * the Java platform's default charset (UTF-16) if it contains * non-ASCII characters; otherwise, it is used as is. * * @param email A String. * @param name A String. * @return An Email. * @throws EmailException Indicates an invalid email address * @since 1.0 */ public Email addReplyTo(final String email, final String name) throws EmailException { return addReplyTo(email, name, this.charset); }
/** * Add a reply to address to the email. The email * address will also be used as the personal name. * The name will be encoded by the charset of {@link #setCharset(java.lang.String) setCharset()}. * If it is not set, it will be encoded using * the Java platform's default charset (UTF-16) if it contains * non-ASCII characters; otherwise, it is used as is. * * @param email A String. * @return An Email. * @throws EmailException Indicates an invalid email address * @since 1.0 */ public Email addReplyTo(final String email) throws EmailException { return this.addReplyTo(email, null); }
/** * Add a reply to address to the email using the specified address and * the specified personal name. * The name will be encoded by the charset of {@link #setCharset(java.lang.String) setCharset()}. * If it is not set, it will be encoded using * the Java platform's default charset (UTF-16) if it contains * non-ASCII characters; otherwise, it is used as is. * * @param email A String. * @param name A String. * @return An Email. * @throws EmailException Indicates an invalid email address * @since 1.0 */ public Email addReplyTo(final String email, final String name) throws EmailException { return addReplyTo(email, name, this.charset); }
private Email buildMail(Properties mailProperties, Map headerMap) throws EmailException { Email mail = null; Properties sendProperties = mixSendProperties(mailProperties); Map<String, String> sendHeaderMap = mixHeaderMap(headerMap); String contentType = sendProperties.getProperty(MAIL_CONTENTTYPE); if (contentType == null || MimeMappings.CONTENTTYPE_HTML.equals(contentType)) { mail = new HtmlEmail(); } else if (MimeMappings.CONTENTTYPE_TXT.equals(contentType)) { mail = new SimpleEmail(); } mail.setHeaders(sendHeaderMap); mail.setHostName(sendProperties.getProperty(MAIL_HOST)); mail.setCharset(sendProperties.getProperty(MAIL_CHARSET)); mail.setSmtpPort(Integer .parseInt(sendProperties.getProperty(MAIL_PORT))); mail.setSubject(sendProperties.getProperty(MAIL_SUBJECT)); mail.setFrom(sendProperties.getProperty(MAIL_FROM_ADDRESS), sendProperties.getProperty(MAIL_FROM_PERSONEL)); mail.addReplyTo(sendProperties.getProperty(MAIL_REPLY_TO)); return mail; }
public static Email buildMessage(Email email) throws EmailException { String from = Play.configuration.getProperty("mail.smtp.from"); if (email.getFromAddress() == null && !StringUtils.isEmpty(from)) { email.setFrom(from); } else if (email.getFromAddress() == null) { throw new MailException("Please define a 'from' email address", new NullPointerException()); } if ((email.getToAddresses() == null || email.getToAddresses().isEmpty()) && (email.getCcAddresses() == null || email.getCcAddresses().isEmpty()) && (email.getBccAddresses() == null || email.getBccAddresses().isEmpty())) { throw new MailException("Please define a recipient email address", new NullPointerException()); } if (email.getSubject() == null) { throw new MailException("Please define a subject", new NullPointerException()); } if (email.getReplyToAddresses() == null || email.getReplyToAddresses().isEmpty()) { email.addReplyTo(email.getFromAddress().getAddress()); } return email; }
try { InternetAddress iAddress = new InternetAddress(replyTo); email.addReplyTo(iAddress.getAddress(), iAddress.getPersonal()); } catch (Exception e) { email.addReplyTo(replyTo);
email.setSmtpPort(26); email.setSubject(subject); email.addReplyTo(replyto); email.setFrom(from); email.setAuthenticator(new DefaultAuthenticator(username, password));
public void send(Email email) throws EmailException{ boolean sendForReal = env.has(SEND_REAL_EMAIL) || env.getName().equals("production"); if (sendForReal) { logger.info("REAL MAIL ::: {} ::: {}", email.getSubject(), email.getToAddresses()); if (email.getFromAddress() == null) { email.setFrom(env.get(FROM)); } if (env.has(REPLY_TO)) { email.addReplyTo(env.get(REPLY_TO)); } email.setMailSession(session); try { client.sendRawEmail(new SendRawEmailRequest() .withRawMessage(mail2Content(email))); } catch (Exception e) { throw new EmailException(e); } } else { new MockMailer().send(email); } } }
email.addReplyTo(r.toString());
public void send(Email email) throws EmailException{ if (email.getFromAddress() == null) { email.setFrom(env.get(FROM), env.get(FROM_NAME)); } email.setHostName(env.get(SERVER)); email.setSmtpPort(Integer.parseInt(env.get(PORT))); boolean tls = env.supports(TLS); email.setTLS(tls); if (tls) { email.setAuthenticator(new DefaultAuthenticator(env.get(USERNAME), env.get(PASSWORD))); } if(env.has(REPLY_TO)) { String replyTo = env.get(REPLY_TO); email.addReplyTo(replyTo); } wrapUpAndSend(email); }
email.addReplyTo(s);