The mailer2 tag library is a complete rewrite of the original Mailer Tag Library. It has the following features:
This tag library requires the following:
Follow these steps to configure your web application with this tag library:
<taglib> <taglib-uri>http://jakarta.apache.org/taglibs/mailer2</taglib-uri> <taglib-location>/WEB-INF/taglibs-mailer2.tld</taglib-location> </taglib>
To use the tags from this library in your JSP pages, add the following directive at the top of each page:
<%@ taglib uri="http://jakarta.apache.org/taglibs/mailer2" prefix="mt" %>
where "mt" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
| JSP tag <mt:mail> constructs an e-mail message. It is the root element of this tag library. <mt:mail> can have the following child tags: <mt:addrecipient>, <mt:attach>, <mt:header>, or <mt:part>. The message will be sent unless the var attribute has been set. | |
| header | JSP tag <mt:header> adds additional headers to an e-mail message. It is a child of <mt:mail> or <mt:part>. |
| addrecipient | JSP tag <mt:addrecipient> adds to, cc, or bcc recipients to an e-mail message. It is a child of <mt:mail>. |
| attach | JSP tag <mt:attach> is used to add attachments to an e-mail message. It is a child of <mt:mail> or <mt:part>. Either the url, or the file, or the message or both name and type attributes should be present. If the url attribute is present, the name and type are derived from the HTTP response. If the filename attribute is present, the name and type are also automatically derived from the filename and a MIME type table. If the message attribute is present, the type is "message/rc822" and the name is the subject of the attached message. If both name and type are present, the body content of the tag is added as an attachment. |
| part | JSP tag <mt:part> is used to create a multipart mail. It is used for HTML and plain text multipart mail alternatives or multipart/digest messages that contain several messages. It is a child of <mt:mail>. Allowed children are <mt:header> and <mt:attach>. Multiple <mt:parts> can be added to an <mt:mail> tag. The type attribute of <mt:mail> should then be one of the multipart/* variants, e.g. multipart/mixed, multipart/related or multipart/alternative. The attachments inside <mt:part> and its optional body content are assumed to be multipart/related. This enables the creation of HTML formatted e-mail. References to images should be be made using cid: URLs. |
| send | JSP tag <mt:send> sends a previously stored message. <mt:send> does not have any child tags. |
| replyto | JSP tag <mt:replyto> adds a reply-to address to an e-mail message. It is a child of mt:mail. |
| sign | JSP tag <mt:sign> is used to S/MIME sign a previously stored message. <mt:sign> does not have any child tags. |
| encrypt | JSP tag <mt:encrypt> is used to S/MIME sign and encrypt a previously stored message. <mt:encrypt> does not have any child tags. |
| save | JSP tag <mt:save> is used to save a previously stored message to the file system. <mt:save> does not have any child tags. |
| load | JSP tag <mt:load> is used to load a message from the file system. <mt:load> does not have any child tags. |
| Availability: 1.0 | |||||
|
JSP tag <mt:mail> constructs an e-mail message. It is the root element of this tag library. <mt:mail> can have the following child tags: <mt:addrecipient>, <mt:attach>, <mt:header>, or <mt:part>. The message will be sent unless the var attribute has been set. |
|||||
| Tag Body | JSP | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| bcc | No | Yes | 1.0 | ||
|
Comma separated list of e-mail addresses to send the message to as blind carbon copy |
|||||
| cc | No | Yes | 1.0 | ||
|
Comma separated list of e-mail addresses to send the message to as carbon copy |
|||||
| from | Yes | Yes | 1.0 | ||
|
The e-mail address from whom the message is sent, or set the context-param org.apache.taglibs.mailer2.from |
|||||
| importance | No | Yes | 1.0 | ||
|
The importance of the message, either "low", "normal" or "high" |
|||||
| mimemessage | No | Yes | 1.0 | ||
|
The name of a JNDI lookup javax.mail.internet.MimePartDataSource to configure the mail Session |
|||||
| password | No | Yes | 1.0 | ||
|
The password to use with PLAIN or LOGIN SMTP authentication, or set the context-param org.apache.taglibs.mailer2.password |
|||||
| port | No | Yes | 1.0 | ||
|
The port of the mail server, default 25, or set the context-param org.apache.taglibs.mailer2.port |
|||||
| replyto | No | Yes | 1.0 | ||
|
The e-mail address to reply-to |
|||||
| scope | No | Yes | 1.0 | ||
|
Scope to store the message in instead of sending it directly, either "page" (default), "request", "session", or "application" |
|||||
| type | No | Yes | 1.0 | ||
|
The Content-Type of the message, default "text/plain" |
|||||
| encoding | No | Yes | 1.0 | ||
|
The character set encoding of the message, default unspecified |
|||||
| server | No | Yes | 1.0 | ||
|
The name of the mail server, default "localhost", or set the context-param org.apache.taglibs.mailer2.server |
|||||
| session | No | Yes | 1.0 | ||
|
The name of a JNDI lookup javax.mail.Session to configure the mail Session |
|||||
| subject | No | Yes | 1.0 | ||
|
The subject of the e-mail message |
|||||
| to | No | Yes | 1.0 | ||
|
Comma separated list of e-mail addresses to send the message to |
|||||
| username | No | Yes | 1.0 | ||
|
The username to use with PLAIN or LOGIN SMTP authentication, or set the context-param org.apache.taglibs.mailer2.username |
|||||
| var | No | No | 1.0 | ||
|
Name of variable to store message in the scope indicated by the scope attribute, instead of sending it directly |
|||||
| background | No | Yes | 1.0 | ||
|
Whether the mail should be sent in a background thread, default true. If true then no feedback (e.g. exceptions) will be returned to the user. ServletContext.log() is used instead |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:mail> tag. Note: the use of the cid: URL scheme to access an embedded logo in an HTML formatted mail message | ||||
|
|
|||||
| header | Availability: 1.0 | ||||
|
JSP tag <mt:header> adds additional headers to an e-mail message. It is a child of <mt:mail> or <mt:part>. |
|||||
| Tag Body | JSP | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| name | Yes | Yes | 1.0 | ||
|
The name of the header |
|||||
| value | No | Yes | 1.0 | ||
|
The value of the header |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:header> tag. | ||||
|
|
|||||
| addrecipient | Availability: 1.0 | ||||
|
JSP tag <mt:addrecipient> adds to, cc, or bcc recipients to an e-mail message. It is a child of <mt:mail>. |
|||||
| Tag Body | JSP | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| type | Yes | No | 1.0 | ||
|
The type of recipient, either "to", "cc", or "bcc" |
|||||
| name | No | Yes | 1.0 | ||
|
The real name of the recipient |
|||||
| address | No | Yes | 1.0 | ||
|
The e-mail address |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:addrecipient> tag. | ||||
|
|
|||||
| attach | Availability: 1.0 | ||||
|
JSP tag <mt:attach> is used to add attachments to an e-mail message. It is a child of <mt:mail> or <mt:part>. Either the url, or the file, or the message or both name and type attributes should be present. If the url attribute is present, the name and type are derived from the HTTP response. If the filename attribute is present, the name and type are also automatically derived from the filename and a MIME type table. If the message attribute is present, the type is "message/rc822" and the name is the subject of the attached message. If both name and type are present, the body content of the tag is added as an attachment. |
|||||
| Tag Body | JSP | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| filename | No | Yes | 1.0 | ||
|
The name of a local file to attach to the part or mail |
|||||
| url | No | Yes | 1.0 | ||
|
The url of a external resource to attach to the part or mail |
|||||
| type | No | Yes | 1.0 | ||
|
The content-type of the body content of the attachment |
|||||
| name | No | Yes | 1.0 | ||
|
The name of the attachment; this is the name under which the attachment can be saved |
|||||
| encoding | No | Yes | 1.0 | ||
|
The encoding of the attachment, default unspecified |
|||||
| message | No | Yes | 1.0 | ||
|
A Message object stored with a previous <mt:mail var="..."> |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:attach> tag. | ||||
|
|
|||||
| part | Availability: 1.0 | ||||
|
JSP tag <mt:part> is used to create a multipart mail. It is used for HTML and plain text multipart mail alternatives or multipart/digest messages that contain several messages. It is a child of <mt:mail>. Allowed children are <mt:header> and <mt:attach>. Multiple <mt:parts> can be added to an <mt:mail> tag. The type attribute of <mt:mail> should then be one of the multipart/* variants, e.g. multipart/mixed, multipart/related or multipart/alternative. The attachments inside <mt:part> and its optional body content are assumed to be multipart/related. This enables the creation of HTML formatted e-mail. References to images should be be made using cid: URLs. |
|||||
| Tag Body | JSP | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| type | No | Yes | 1.0 | ||
|
The content-type of the body of this part |
|||||
| encoding | No | Yes | 1.0 | ||
|
The character set encoding of the body of this part, default unspecified |
|||||
| Variables | None | ||||
| Examples | See mt:mail | ||||
|
|
|||||
| send | Availability: 1.0 | ||||
|
JSP tag <mt:send> sends a previously stored message. <mt:send> does not have any child tags. |
|||||
| Tag Body | empty | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| message | Yes | Yes | 1.0 | ||
|
The message to send |
|||||
| background | No | Yes | 1.0 | ||
|
Whether the mail should be sent in a background thread, default true. If true then no feedback (e.g. exceptions) will be shown to the user. ServletContext.log() is used instead |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:send> tag. | ||||
|
|
|||||
| replyto | Availability: 1.0 | ||||
|
JSP tag <mt:replyto> adds a reply-to address to an e-mail message. It is a child of mt:mail. |
|||||
| Tag Body | JSP | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| name | No | Yes | 1.0 | ||
|
The real name of the reply-to recipient |
|||||
| address | No | Yes | 1.0 | ||
|
The e-mail address to reply-to |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:replyto> tag. | ||||
|
|
|||||
| sign | Availability: 1.0 | ||||
|
JSP tag <mt:sign> is used to S/MIME sign a previously stored message. <mt:sign> does not have any child tags. |
|||||
| Tag Body | empty | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| message | Yes | Yes | 1.0 | ||
|
The message to sign |
|||||
| keystore | Yes | Yes | 1.0 | ||
|
The name of the keystore file (e.g. keystore.p12 or keystore.pfx) |
|||||
| storepass | No | Yes | 1.0 | ||
|
The password to open the keystore |
|||||
| storetype | No | Yes | 1.0 | ||
|
The type of keystore file, e.g. "PKCS12" (default, for .p12 or .pfx keystores), or "JKS", etc. |
|||||
| alias | Yes | Yes | 1.0 | ||
|
The alias of the private key in the keystore to sign the message with |
|||||
| var | Yes | No | 1.0 | ||
|
The name of the variable to store the signed message in |
|||||
| scope | No | Yes | 1.0 | ||
|
The scope to store the signed message in, either "page" (default), "request", "session", or "application" |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:sign> tag. | ||||
|
|
|||||
| encrypt | Availability: 1.0 | ||||
|
JSP tag <mt:encrypt> is used to S/MIME sign and encrypt a previously stored message. <mt:encrypt> does not have any child tags. |
|||||
| Tag Body | empty | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| message | Yes | Yes | 1.0 | ||
|
The message to encrypt |
|||||
| keystore | Yes | Yes | 1.0 | ||
|
The name of the keystore file (e.g. keystore.p12 or keystore.pfx) |
|||||
| storepass | No | Yes | 1.0 | ||
|
The password to open the keystore |
|||||
| storetype | No | Yes | 1.0 | ||
|
The type of keystore file, e.g. "PKCS12" (default, for .p12 or .pfx keystores), or "JKS", etc. |
|||||
| alias | Yes | Yes | 1.0 | ||
|
The alias of the private key in the keystore to encrypt the message with |
|||||
| var | Yes | No | 1.0 | ||
|
The name of the variable to store the encrypted message in |
|||||
| scope | No | Yes | 1.0 | ||
|
The scope to store the encrypted message in, either "page" (default), "request", "session", or "application" |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:encrypt> tag. | ||||
|
|
|||||
| save | Availability: 1.0 | ||||
|
JSP tag <mt:save> is used to save a previously stored message to the file system. <mt:save> does not have any child tags. |
|||||
| Tag Body | empty | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| message | Yes | Yes | 1.0 | ||
|
The message to save |
|||||
| filename | Yes | Yes | 1.0 | ||
|
The location to save the message |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:save> tag. | ||||
|
|
|||||
| load | Availability: 1.0 | ||||
|
JSP tag <mt:load> is used to load a message from the file system. <mt:load> does not have any child tags. |
|||||
| Tag Body | empty | ||||
| Restrictions |
None |
||||
| Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
| filename | Yes | Yes | 1.0 | ||
|
The location to load the message from |
|||||
| var | Yes | Yes | 1.0 | ||
|
The name of the variable to store the message in |
|||||
| scope | No | No | 1.0 | ||
|
The scope to store the message in, either "page" (default), "request", "session", or "application" |
|||||
| Variables | None | ||||
| Examples | Example usage of the <mt:load> tag. | ||||
|
|
|||||
See the example application mailer2-examples.war for examples of the usage of the tags from this custom tag library.
Java programmers can view the java class documentation for this tag library as javadocs.
Review the complete revision history of this tag library.