|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.xml.AbstractXMLProducer org.apache.cocoon.xml.AbstractXMLPipe org.apache.cocoon.transformation.AbstractTransformer org.apache.cocoon.transformation.AbstractSAXTransformer org.apache.cocoon.mail.transformation.SendMailTransformer
public class SendMailTransformer
The SendMailTransformer
send mails with optional attachments using a SMTP
server and delivers furthermore a status report of each sent mail.
The SendMailTransformer requires the Sun's JavaMail API implementation. Please download and copy the following files to the Cocoon lib directory:
mail.jar
from
http://java.sun.com/products/javamail/
activation.jar
from
http://java.sun.com/products/javabeans/glasgow/jaf.html
Use the following sitemap component declaration to define, configure and
parameterize the transformer.
in the map:sitemap/map:components/map:transformers
:
<map:transformer name="sendmail" src="org.apache.cocoon.mail.transformation.SendMailTransformer"> <smtphost>smtp.foo.com</smtphost> <from>sender@localhost</from> </map:transformer>where
Furthermore, these parameters can be defined in the sitemap pipeline section:
<map:parameter name="to" value="customer1@target.com,customer2@target.com"/>
More configurations can be made in a specific configuration file, which can be retrieved with a generator as the input document. The input document should have the following configuration entities:
Input document sample:
<?xml version="1.0" encoding="UTF-8"?> <document xmlns:email="http://apache.org/cocoon/transformation/sendmail"> <email:sendmail> <email:smtphost>hostname.company.com</email:smtphost> <email:from>info@company.com</email:from> <email:to>customer3@target.com</email:to> <email:to>customer4@target.com</email:to> <email:to>customer5@target.com</email:to> <email:to>customer6@target.com</email:to> <email:subject>subject-content</email:subject> <email:body src="cocoon:/softwareupdate.html?locale=en&country=UK"/> <!-- <email:body>some Text</email:body> --> <email:attachment name="hello.html" mime-type="text/html"> <email:content> Dear Customer, please visit out new Product-Shop. </email:content> </email:attachment> <email:attachment name="hello2.html" mime-type="text/html" src="cocoon:/src1"/> <email:attachment name="hello3.html" mime-type="text/html" url="C:\path\softwareupdate.html"/> <email:attachment name="hello.gif" mime-type="image/gif" url="c:\path\powered.gif"/> </email:sendmail> </document>
After the transformation a report will be generated, where the state for each sent mail can be seen. In case of an exception, the exception-message and a stacktrace will be reported.
FIXME: Known Issues:
Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer |
---|
context, defaultNamespaceURI, EMPTY_ATTRIBUTES, emptyAttributes, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.transformation.Transformer |
---|
ROLE |
Constructor Summary | |
---|---|
SendMailTransformer()
create a new Transformer |
Method Summary | |
---|---|
void |
configure(Configuration configuration)
|
void |
endTransformingElement(String uri,
String name,
String raw)
Start processing elements of our namespace. |
static InternetAddress[] |
getAddresses(org.apache.cocoon.mail.transformation.SendMailTransformer.AddressHandler[] handlerArr)
|
void |
recycle()
Recycle the producer by removing references, and resetting handlers to null (empty) implementations. |
void |
setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters par)
invoked every time when the transformer is triggered by the pipeline |
void |
startTransformingElement(String uri,
String name,
String raw,
Attributes attr)
Start processing elements of our namespace. |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
setConsumer, setContentHandler, setLexicalHandler |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
---|
setConsumer |
Field Detail |
---|
public static final String NAMESPACE
public static final String ELEMENT_SENDMAIL
public static final String ELEMENT_SMTPHOST
public static final String ELEMENT_SMTPPORT
public static final String ELEMENT_MAILFROM
public static final String ELEMENT_MAILTO
public static final String ELEMENT_REPLYTO
public static final String ELEMENT_MAILSUBJECT
public static final String ELEMENT_MAILBODY
public static final String ELEMENT_ATTACHMENT
public static final String ELEMENT_ATTACHMENT_CONTENT
public static final String ELEMENT_EMAIL_PREFIX
public static final String ELEMENT_ERROR
public static final String ELEMENT_SUCCESS
public static final String ELEMENT_FAILURE
public static final String ELEMENT_RESULT
public static final String DEFAULT_BODY_MIMETYPE
protected static final int MODE_NONE
protected static final int MODE_SMTPHOST
protected static final int MODE_FROM
protected static final int MODE_TO
protected static final int MODE_SUBJECT
protected static final int MODE_BODY
protected static final int MODE_ATTACHMENT
protected static final int MODE_ATTACHMENT_CONTENT
protected static final int MODE_REPLY_TO
protected static final int MODE_SMTPPORT
public static final String PARAM_SMTPHOST
public static final String PARAM_SMTPPORT
public static final String PARAM_FROM
public static final String PARAM_TO
public static final String PARAM_REPLY_TO
public static final String PARAM_SUBJECT
public static final String PARAM_BODY
public static final String PARAM_SENDPARTIAL
protected int mode
protected List toAddresses
protected List replyToAddresses
protected List defaultToAddresses
protected List defaultReplyToAddresses
protected List attachments
protected String subject
protected String body
protected String bodyURI
protected String bodyMimeType
protected String mailHost
protected int mailPort
protected String fromAddress
protected org.apache.cocoon.mail.transformation.SendMailTransformer.AttachmentDescriptor attachmentDescriptor
protected int port
protected String contextPath
protected boolean sendPartial
protected Message smtpMessage
protected String defaultSmtpHost
protected int defaultSmtpPort
protected String defaultFromAddress
protected List usedSources
Constructor Detail |
---|
public SendMailTransformer()
Method Detail |
---|
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
configure
in class AbstractSAXTransformer
ConfigurationException
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException
setup
in interface SitemapModelComponent
setup
in class AbstractSAXTransformer
ProcessingException
SAXException
IOException
public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws SAXException
AbstractSAXTransformer
startTransformingElement
in class AbstractSAXTransformer
uri
- The namespace of the element.name
- The local name of the element.raw
- The qualified name of the element.attr
- The attributes of the element.
SAXException
public void endTransformingElement(String uri, String name, String raw) throws SAXException, ProcessingException
AbstractSAXTransformer
endTransformingElement
in class AbstractSAXTransformer
uri
- The namespace of the element.name
- The local name of the element.raw
- The qualified name of the element.
SAXException
ProcessingException
public static InternetAddress[] getAddresses(org.apache.cocoon.mail.transformation.SendMailTransformer.AddressHandler[] handlerArr)
public void recycle()
AbstractXMLProducer
recycle
in interface Recyclable
recycle
in class AbstractSAXTransformer
Recyclable.recycle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |