/** * Adds a header ( name, value ) to the headers Map. * * @param name A String with the name. * @param value A String with the value. * @since 1.0 * @throws IllegalArgumentException if either {@code name} or {@code value} is null or empty */ public void addHeader(final String name, final String value) { if (EmailUtils.isEmpty(name)) { throw new IllegalArgumentException("name can not be null or empty"); } if (EmailUtils.isEmpty(value)) { throw new IllegalArgumentException("value can not be null or empty"); } this.headers.put(name, value); }
/** * Set the text content. * * @param aText A String. * @return An HtmlEmail. * @throws EmailException see javax.mail.internet.MimeBodyPart * for definitions * @since 1.0 */ public HtmlEmail setTextMsg(final String aText) throws EmailException { if (EmailUtils.isEmpty(aText)) { throw new EmailException("Invalid message supplied"); } this.text = aText; return this; }
/** * Set the HTML content. * * @param aHtml A String. * @return An HtmlEmail. * @throws EmailException see javax.mail.internet.MimeBodyPart * for definitions * @since 1.0 */ public HtmlEmail setHtmlMsg(final String aHtml) throws EmailException { if (EmailUtils.isEmpty(aHtml)) { throw new EmailException("Invalid message supplied"); } this.html = aHtml; return this; }
/** * Supply a mail Session object from a JNDI directory. * * @param jndiName name of JNDI resource (javax.mail.Session type), resource * if searched in java:comp/env if name does not start with "java:" * @throws IllegalArgumentException if the JNDI name is null or empty * @throws NamingException if the resource cannot be retrieved from JNDI directory * @since 1.1 */ public void setMailSessionFromJNDI(final String jndiName) throws NamingException { if (EmailUtils.isEmpty(jndiName)) { throw new IllegalArgumentException("JNDI name missing"); } Context ctx = null; if (jndiName.startsWith("java:")) { ctx = new InitialContext(); } else { ctx = (Context) new InitialContext().lookup("java:comp/env"); } this.setMailSession((Session) ctx.lookup(jndiName)); }
/** * Create a folded header value containing 76 character chunks. * * @param name the name of the header * @param value the value of the header * @return the folded header value * @throws IllegalArgumentException if either the name or value is null or empty */ private String createFoldedHeaderValue(final String name, final String value) { if (EmailUtils.isEmpty(name)) { throw new IllegalArgumentException("name can not be null or empty"); } if (value == null || EmailUtils.isEmpty(value)) { throw new IllegalArgumentException("value can not be null or empty"); } try { return MimeUtility.fold(name.length() + 2, MimeUtility.encodeText(value, this.charset, null)); } catch (final UnsupportedEncodingException e) { return value; } }
if (EmailUtils.isEmpty(aContentType))
public Email setMsg(final String msg) throws EmailException if (EmailUtils.isEmpty(msg))
/** * Set the content of the mail. * * @param msg A String. * @return An Email. * @throws EmailException see javax.mail.internet.MimeBodyPart * for definitions * @since 1.0 */ @Override public Email setMsg(final String msg) throws EmailException { if (EmailUtils.isEmpty(msg)) { throw new EmailException("Invalid message supplied"); } setContent(msg, EmailConstants.TEXT_PLAIN); return this; } }
if (EmailUtils.isEmpty(name))
if (EmailUtils.isEmpty(file.getName()))
if (EmailUtils.isEmpty(name))
throws EmailException if (EmailUtils.isEmpty(name))
if (EmailUtils.isEmpty(charsetName))
if (EmailUtils.isEmpty(msg))
throws EmailException if (EmailUtils.isEmpty(name))
/** * Adds a header ( name, value ) to the headers Map. * * @param name A String with the name. * @param value A String with the value. * @since 1.0 * @throws IllegalArgumentException if either {@code name} or {@code value} is null or empty */ public void addHeader(final String name, final String value) { if (EmailUtils.isEmpty(name)) { throw new IllegalArgumentException("name can not be null or empty"); } if (EmailUtils.isEmpty(value)) { throw new IllegalArgumentException("value can not be null or empty"); } this.headers.put(name, value); }
/** * Set the HTML content. * * @param aHtml A String. * @return An HtmlEmail. * @throws EmailException see javax.mail.internet.MimeBodyPart * for definitions * @since 1.0 */ public HtmlEmail setHtmlMsg(final String aHtml) throws EmailException { if (EmailUtils.isEmpty(aHtml)) { throw new EmailException("Invalid message supplied"); } this.html = aHtml; return this; }
/** * Set the text content. * * @param aText A String. * @return An HtmlEmail. * @throws EmailException see javax.mail.internet.MimeBodyPart * for definitions * @since 1.0 */ public HtmlEmail setTextMsg(final String aText) throws EmailException { if (EmailUtils.isEmpty(aText)) { throw new EmailException("Invalid message supplied"); } this.text = aText; return this; }
/** * Set the content of the mail. * * @param msg A String. * @return An Email. * @throws EmailException see javax.mail.internet.MimeBodyPart * for definitions * @since 1.0 */ @Override public Email setMsg(final String msg) throws EmailException { if (EmailUtils.isEmpty(msg)) { throw new EmailException("Invalid message supplied"); } setContent(msg, EmailConstants.TEXT_PLAIN); return this; } }