0
votes

Iam trying to use an email module in exist-db. For this purpose Iam using mail-send-email function describing in this article http://en.wikibooks.org/wiki/XQuery/Sending_E-mail but its not working and I dont know why. The exide IDE show the following error: exerr:ERROR Could not send message(s)java.net.UnknownHostException: smtp.google.com [at line 29, column 6]

xquery version "1.0";

declare namespace mail="http://exist-db.org/xquery/mail";

declare variable $message {
  <mail>
    <from>some name of recipient &lt;[email protected]&gt;</from>
    <to>[email protected]</to>
    <subject>Hello world</subject>
    <message>
      <text>Hello world!</text>
    </message>
  </mail>
};

if ( mail:send-email($message, 'smtp.google.com', ()) ) then
  <h1>Sent Message OK :-)</h1>
else
  <h1>Could not Send Message :-(</h1>

If somebody know how to send email via exist-db I would be very thankful. Thanks in advance!

1

1 Answers

2
votes

The error message is because there is no domain smtp.google.com.

$ host smtp.google.com
Host smtp.google.com not found: 3(NXDOMAIN)

I'd recommend to set up a local MTA and leave the $server field blank:

$server? The SMTP server. If empty, then it tries to use the local sendmail program.

A local mail server will also enable you to authenticate against an SMTP server, which is required by most of them – for example gmail, which you probably wanted to use.