/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { String } from "../../types/java/lang/String"; import type { Mail } from "../../types/senselogic/sitevision/api/mail/Mail"; import type { Builder } from "../../types/senselogic/sitevision/api/base/Builder"; /** * Builder to create a Mail instances that can be sent. * *
* MailBuilder has some mandatory attributes: *
** MailBuilder also has some optional attributes: *
*null
* (will use the from address for the site, with fallback to the from address of the server).
* null.
* null.
* null.
* * Note that there are three types of recipients (TO, CC, BCC). This builder will not detect or automatically handle duplicates * cross types. It is up to the mail builder user to ensure addresses aren't added as different types of recipients. *
* ** Using the MailBuilder is pretty straightforward, if you remember that it is stateful. Conceptually you * would typically use it like this: *
*
* When you have built a Mail instance, you can re-use the MailBuilder to build more instances. Something like:
*
* Example of how this strategy could be implemented in server-side JavaScript:
* (send one "personalized" mail to Magnus and another one to Klas)
*
// Import MailUtil in apps (WebApp, RESTApp, Widget, MCPServer etc)
* // NOTE! Use the require function instead in other server-side Javascripts (e.g. Script module), i.e:
* // const mailUtil = require("MailUtil");
* import mailUtil from "@sitevision/api/server/MailUtil";
*
* // Create a mail builder instance
* const mailBuilder = mailUtil.getMailBuilder();
*
* // Create a mail
* let mail = mailBuilder
* .setSubject("Hello buddy")
* .setTextMessage("How are you Magnus?")
* .addRecipient("magnus.lovgren@sitevision.se")
* .build();
*
* // Send mail
* if (mail.send()) {
* console.log("Mail to Magnus successfully sent!");
* } else {
* console.log("Mail to Magnus could NOT be sent!");
* }
*
* // Create another mail, with other message and recipient
* mail = mailBuilder
* .setTextMessage("How are you Klas?")
* .clearRecipients()
* .addRecipient("Klash <klas.hedstrom@sitevision.se>")
* .build();
*
* // Send mail
* if (mail.send()) {
* console.log("Mail to Klas successfully sent!");
* } else {
* console.log("Mail to Klas could NOT be sent!");
* }
*
*
* Note that Velocity has some caveats when working fluently with a Builder!
* It is not allowed to add whitespace between chained method calls.
* This is an example of how to use line breaks and indentation in Velocity when working with a Builder:
*
* ## Get the mail util and the mail builder
* #set ($mailUtil = $sitevisionUtils.mailUtil)
* #set ($mailBuilder = $mailUtil.mailBuilder)
*
* ## Create a mail
* #set ($mail = $mailBuilder.setSubject('Hello buddy'
* ).setTextMessage('How are you Magnus?'
* ).addRecipient('magnus.lovgren@sitevision.se'
* ).build())
*
* * Tip! The {@link senselogic.sitevision.api.base.Builder Builder interface documentation} contains * more information about Builders and how to work with them! *
* *
* An instance of the Sitevision class implementing this interface can be obtained via
* {@link senselogic.sitevision.api.mail.MailUtil#getMailBuilder()}.
* See {@link senselogic.sitevision.api.mail.MailUtil} for how to obtain an instance of the MailUtil interface.
*
* The from address can be in basic format ("example@domain.com") * or in "mailbox" format ("Some Name <example@domain.com>") *
** Note! Even if you explicitly set a from address, it might not be used when the mail is sent. * It will only be used if it is valid and the domain part of the address is also matching the DKIM signing domain (if DKIM is setup). *
** If no from address is set or the from address is invalid or the domain part of the address is not matching the DKIM signing domain, * the most appropriate address from the site (or server) will be used instead. *
* @param aFromAddress the from address. A whitespace-only address will be ignored, default (null) will be set instead. * @return this builder */ setFrom(aFromAddress: String | string): MailBuilder; /** * Adds a reply-to address. * ** The reply-to address can be in basic format ("example@domain.com") * or in "mailbox" format ("Some Name <example@domain.com>") *
* @param aReplyToAddress a reply-to address. A null or whitespace-only address will be ignored. * @return this builder */ addReplyTo(aReplyToAddress: String | string): MailBuilder; /** * Removes all previously added reply-to addresses. * @return this builder */ clearReplyTos(): MailBuilder; /** * Sets the subject. * @param aSubject a subject * @return this builder */ setSubject(aSubject: String | string): MailBuilder; /** * Sets the text message. * @param aTextMessage a text message * @return this builder */ setTextMessage(aTextMessage: String | string): MailBuilder; /** * Sets the html message. * @param aHtmlMessage a html message * @return this builder * @since Sitevision 4.3 */ setHtmlMessage(aHtmlMessage: String | string): MailBuilder; /** * Adds a recipient address (TO). * ** The recipient address can be in basic format ("example@domain.com") * or in "mailbox" format ("Some Name <example@domain.com>") *
* @param aRecipientAddress a recipient address. A null or whitespace-only address will be ignored. * @return this builder */ addRecipient(aRecipientAddress: String | string): MailBuilder; /** * Removes all previously added recipient addresses (TO). * @return this builder */ clearRecipients(): MailBuilder; /** * Convenience method for removing all addresses for all recipient types (TO/CC/BCC). * @return this builder * @since Sitevision 3.6.3 * @see #clearRecipients() * @see #clearCopyRecipients() * @see #clearBlindCopyRecipients() */ clearAllRecipients(): MailBuilder; /** * Adds a carbon copy recipient address (CC). * ** The carbon copy address can be in basic format ("example@domain.com") * or in "mailbox" format ("Some Name <example@domain.com>") *
* @param aCopyRecipientAddress a carbon copy recipient address. A null or whitespace-only address will be ignored. * @return this builder * @since Sitevision 3.6.3 */ addCopyRecipient(aCopyRecipientAddress: String | string): MailBuilder; /** * Removes all previously added carbon copy recipient addresses (CC). * @return this builder * @since Sitevision 3.6.3 */ clearCopyRecipients(): MailBuilder; /** * Adds a blind carbon copy recipient address (BCC). * ** The blind carbon copy address can be in basic format ("example@domain.com") * or in "mailbox" format ("Some Name <example@domain.com>") *
* @param aBlindCopyRecipientAddress a blind carbon copy recipient address. A null or whitespace-only address will be ignored. * @return this builder * @since Sitevision 3.6.3 */ addBlindCopyRecipient( aBlindCopyRecipientAddress: String | string ): MailBuilder; /** * Removes all previously added blind carbon copy recipient addresses (BCC). * @return this builder * @since Sitevision 3.6.3 */ clearBlindCopyRecipients(): MailBuilder; /** * Creates a Mail instance using current state of this builder. * @return a mail that can be sent * @throws IllegalStateException will be thrown if subject is null, if there are no recipients or if a recipient address is invalid, if the from address, a copy address, blind copy address or reply-to address is invalid. */ build(): Mail; } declare namespace MailBuilder {} declare var mailBuilder: MailBuilder; export default mailBuilder;