E-Mail Driver for Scriptella.
Allows sending E-Mails via SMTP.
General information
Driver class: | scriptella.driver.mail.Driver |
URL: | URL specifies TO recipients using the mailto scheme: mailto:sAddress[sHeaders] |
Runtime dependencies: |
mail.jar
and activation.jar |
Driver Specific Properties
Name |
Description |
Required |
type |
Specifies type of E-Mail message content: text or html . |
No, default value is text . |
subject |
Specifies e-mail subject. |
No. |
mail.host |
Specifies the default Mail server.
| No, see JavaMail Environment Properties for details |
mail.from |
Specifies e-mail address of sender.
| No, see JavaMail Environment Properties for details |
Properties substitution
Mail script elements support ${property} or $property syntax for properties/variables substition.
Additionally connection URL parameter supports dynamically resolved binding variables.
Example:
mailto:$email , the email variable would be reevaluated if mail script is executed by a parent query.
Notes:
- In addition to the above mentioned properties the driver supports all JavaMail environment properties.
- Connection properties may be specified inside a connection element or as a a part of URL, e.g.
mailto:user@nosuchhost.com?subject=Hello
- This driver supports dynamic properties substitution in an URL,
e.g.
mailto:$email?subject=$subject
,it makes possible sending emails to recipients specified by in a row set.
Examples
The following example sends a simple text message
<etl>
<connection driver="mail" url="mailto:user@nosuchhost.com?subject=Hello"
classpath="mail.jar:activation.jar">
mail.smtp.host=mail.host.name
mail.user=user
mail.password=password
mail.from=Firstname Lastname <user@nosuchhost.com>
</connection>
<script>Message produced by Scriptella ETL</script>
</etl>
Use type=html property to send HTML content.
<etl>
<connection driver="mail" url="mailto:user@nosuchhost.com?subject=Hello"
classpath="mail.jar:activation.jar">
type=html
mail.smtp.host=mail.host.name
mail.user=user
mail.password=password
mail.from=Firstname Lastname <user@nosuchhost.com>
</connection>
<script><![CDATA[
<html>
<body>
Hello,
<hr>
<a href="http://scriptella.javaforge.com/" title="Powered by Scriptella ETL">
<img src="http://scriptella.javaforge.com/images/scriptella-powered.gif"
width="88" height="31" border="0" alt="Powered by Scriptella ETL">
</a>
</body>
</html>]]>
</script>
</etl>
The following example sends a message to a list selected from the database
<etl>
<connection id="mail" driver="mail" url="mailto:$email?subject=Hello $name"
classpath="mail.jar:activation.jar">
mail.smtp.host=mail.host.name
mail.user=user
mail.password=password
mail.from=Administrator <user@nosuchhost.com>
</connection>
<connection id="db" .../>
<query connection-id="db" >
SELECT * FROM Users
<script connection-id="mail">
#$rownum
Message produced by Scriptella ETL
</script>
</query>
</etl>
|