Sending e-mails with cx:send-mail

I'm trying to send a mail from XProc with cx:send-mail, but I'm having
trouble getting it working. I've read the discussion[1] that resulted in
the implementation of the experimental step, and I also found mention of it
in the Calabash configuration documentation[2], but I haven't got it
working. So here's my pipeline:

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="
http://www.w3.org/ns/xproc-step" xmlns:cx="
http://xmlcalabash.com/ns/extensions" version="1.0">
    <p:output port="result"/>
    <p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl
"/>
    <cx:send-mail xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
        <p:input port="source">
            <p:inline exclude-inline-prefixes="em rf cx">
                <em:Message>
                    <rf:from>
                        <em:Address>
                            <em:adrs>mailto:josteinaj@gmail.com</em:adrs>
                            <em:name>XProc</em:name>
                        </em:Address>
                    </rf:from>
                    <rf:to>
                        <em:Address>
                            <em:adrs>mailto:josteinaj@gmail.com</em:adrs>
                            <em:name>Jostein</em:name>
                        </em:Address>
                    </rf:to>
                    <rf:subject>Hello, world!</rf:subject>
                    <em:content type='text/plain'>Hope you are well formed.
Regards, XProc.</em:content>
                </em:Message>
            </p:inline>
        </p:input>
    </cx:send-mail>
</p:declare-step>

(It's essentially the same as Norman's example in the earlier discussion. I
added mailto: in the adrs element since they do that in the RFC822
example[3])

The thread tells me that it should be configured in ~/.calabash with:
<cc:sendmail host="outbound.mailhop.org" port="2525" username="jdoe"
password="likeidtellyou"/>

The documentation tells me that it should be configured either with Java
system properties:
com.xmlcalabash.mail-host=hostname
com.xmlcalabash.mail-port=portnumber
com.xmlcalabash.mail-username=name
com.xmlcalabash.mail-password=password
...or in ~/.calabash:
<cc:saxon-configuration-property host="hostname" port="portnumber"
username="name" password="password"/>

I've downloaded JavaMail and added mail.jar to the classpath for Calabash.
Setting the Java system properties or using cc:sendmail doesn't seem to do
anything; I just get the same error as if I hadn't tried to configure SMTP
at all. If I use cc:saxon-configuration-property I get "XProcException:
Configuration option 'saxon-configuration-property' cannot have a null key
or value". I've also added "<implementation type="cx:send-mail"
class-name="com.xmlcalabash.extensions.SendMail"/>" to ~/.calabash, hoping
that that would work, but nothing changed.

This is the error I get:
~$ calabash -D send-mail-test.xpl
Cannot find CatalogManager.properties
DEBUG: setDebug: JavaMail version 1.4.5
Jul 18, 2012 12:00:03 AM com.xmlcalabash.drivers.Main error
SEVERE: Pipeline failed: java.lang.NullPointerException
java.lang.NullPointerException
at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1554)
 at com.xmlcalabash.extensions.SendMail.run(Unknown Source)
at com.xmlcalabash.runtime.XAtomicStep.run(Unknown Source)
 at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
 at com.xmlcalabash.drivers.Main.run(Unknown Source)
at com.xmlcalabash.drivers.Main.main(Unknown Source)

What am I doing wrong? And what is the right way to configure Calabash for
sending mails?

[1] http://lists.w3.org/Archives/Public/xproc-dev/2011Nov/thread.html#msg4
[2] http://xmlcalabash.com/docs/reference/configuration.html#cfg.
[3] http://tools.ietf.org/html/draft-klyne-message-rfc822-xml-03

Jostein

Received on Tuesday, 17 July 2012 22:07:33 UTC