/** * Sets the FROM address from {@link Address}. * * @param from {@link Address} * @return this * @see #from(EmailAddress) */ public T from(final Address from) { return from(EmailAddress.of(from)); }
/** * Appends TO address. * * @param to Address may be specified with personal name like this: {@code Jenny Doe <email@foo.com>}. * @return this * @see #to(EmailAddress) */ public T to(final String to) { return to(EmailAddress.of(to)); }
/** * Resets all REPLY-To addresses. */ public T resetReplyTo() { this.replyTo = EmailAddress.EMPTY_ARRAY; return _this(); }
/** * Adds {@link EmailAttachment}s. * * @param attachments {@link List} of {@link EmailAttachment}s to add. * @return this */ public T attachments(final List<EmailAttachment<? extends DataSource>> attachments) { for (final EmailAttachment<?> attachment : attachments) { attachment(attachment); } return _this(); }
/** * Appends TO addresses. * * @param tos vararg of {@link EmailAddress}es to set. * @return this */ public T to(final EmailAddress... tos) { this.to = valueOrEmptyArray(tos); return _this(); }
/** * Embed {@link EmailAttachment} to last message. No header is changed. * * @param attachment {@link EmailAttachment} * @return this * @see #storeAttachment(EmailAttachment) */ public T embeddedAttachment(final EmailAttachment<? extends DataSource> attachment) { storeAttachment(attachment); final List<EmailMessage> messages = messages(); final int size = messages.size(); if (size > 1) { // Add to last message final int lastMessagePos = size - 1; final EmailMessage lastMessage = messages.get(lastMessagePos); attachment.setEmbeddedMessage(lastMessage); } return _this(); }
/** * Adds plain message text. * * @param text The text to add as a {@link String}. * @return this * @see #message(String, String) */ public T textMessage(final String text) { return message(text, MimeTypes.MIME_TEXT_PLAIN); }
/** * Sets one or more CC address. * * @param ccs array of {@link Address}s to set. * @return this * @see #cc(EmailAddress...) */ public T cc(final Address... ccs) { return cc(EmailAddress.of(ccs)); }
/** * Appeds one or more REPLY-TO address. * * @param replyTos array of {@link Address}es to set. * @return this * @see #replyTo(EmailAddress...) */ public T replyTo(final Address... replyTos) { return replyTo(EmailAddress.of(replyTos)); }
/** * Sets message subject with specified encoding to override default platform encoding. * If the subject contains non US-ASCII characters, it will be encoded using the specified charset. * If the subject contains only US-ASCII characters, no encoding is done and it is used as-is. * The application must ensure that the subject does not contain any line breaks. * See {@link javax.mail.internet.MimeMessage#setSubject(String, String)}. * * @param subject The message subject * @param encoding The encoding for the message subject. * @return this */ public T subject(final String subject, final String encoding) { subject(subject); this.subjectEncoding = encoding; return _this(); }
/** * @see #attachment(EmailAttachment) */ public T attachment(final EmailAttachmentBuilder builder) { return attachment(builder.buildByteArrayDataSource()); }
/** * Attaches the embedded attachment: Content ID will be set if missing from attachment's file name. * * @param builder {@link EmailAttachmentBuilder} * @return this * @see #embeddedAttachment(EmailAttachment) */ public T embeddedAttachment(final EmailAttachmentBuilder builder) { builder.setContentIdFromNameIfMissing(); // https://github.com/oblac/jodd/issues/546 // https://github.com/oblac/jodd/issues/404#issuecomment-297011351 // content disposition will be set to "inline" builder.inline(true); return embeddedAttachment(builder.buildByteArrayDataSource()); }
/** * Appends REPLY-TO addresses. * * @param replyTo vararg of {@link EmailAddress}es to set. * @return this */ public T replyTo(final EmailAddress... replyTo) { this.replyTo = ArraysUtil.join(this.replyTo, valueOrEmptyArray(replyTo)); return _this(); }
/** * Embed {@link EmailAttachment} to last message. No header is changed. * * @param attachment {@link EmailAttachment} * @return this * @see #storeAttachment(EmailAttachment) */ public T embeddedAttachment(final EmailAttachment<? extends DataSource> attachment) { storeAttachment(attachment); final List<EmailMessage> messages = messages(); final int size = messages.size(); if (size > 1) { // Add to last message final int lastMessagePos = size - 1; final EmailMessage lastMessage = messages.get(lastMessagePos); attachment.setEmbeddedMessage(lastMessage); } return _this(); }
/** * Sets headers. * * @param headersToSet Headers to set. * @return this * @see #header(String, String) */ public T headers(final Enumeration<Header> headersToSet) { while (headersToSet.hasMoreElements()) { final Header header = headersToSet.nextElement(); header(header.getName(), header.getValue()); } return _this(); }
/** * Adds HTML message. * * @param html The HTML to add as a {@link String}. * @param encoding The encoding as a {@link String}. * @return this * @see #message(EmailMessage) */ public T htmlMessage(final String html, final String encoding) { return message(new EmailMessage(html, MimeTypes.MIME_TEXT_HTML, encoding)); }
/** * Appends CC address. * * @param personalName personal name. * @param cc email address. * @return this * @see #cc(EmailAddress) */ public T cc(final String personalName, final String cc) { return cc(new EmailAddress(personalName, cc)); }