...
To be able to send any emails from Weave you must provide Weave with the details of a mail server that will be used to send the emails.
This is done using the com.cohga.server.mail
configuration options
Code Block |
---|
| xml |
---|
| xml |
---|
title | Basic mail server setup | xml |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:com.cohga.server.config#1.0" xmlns:mail="urn:com.cohga.server.mail#1.0">
<mail:smtp>
<host>mail.sforbes.net</host>
<username>sforbes</username>
<password>ENCEAUFJCUABCFXEMFQABFJEBZJAKFCXGME</password>
</mail:smtp>
</config>
|
...
The default values that can be setup in an email config are the from
address, the to
addresses, the cc
addresses, the bcc
addresses, the email subject
and the email message
.
Code Block |
---|
| xml |
---|
| xml |
---|
title | Basic emails settingsxml |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:com.cohga.server.config#1.0" xmlns:report="urn:com.cohga.server.report#1.0">
<report:email id="feedback">
<from>noreply@sforbes.net</from>
<to>feedback@sforbes.net</to>
</report:email>
</config>
|
...
There are a couple of special markers that can be used in the addresses, they are ${userid
} and ${domain
}.
They allow you to substitute the current userid and the servers domain into the address. Note that the domain is guessed based on the canonical host name of the Weave server, and defaults to 'local' if it can't be determined.
So you could use the following to try and guess the from
address of the user
Code Block |
---|
| xml |
---|
| xml |
---|
title | From address from userid and hosts domain | xml |
---|
|
<from>${userid}@${domain}</from>
|
or
Code Block |
---|
| xml |
---|
| xml |
---|
title | From address from userid with a fixed domain | xml |
---|
|
<from>${userid}@sforbes.net</from>
|
...
Similarly the default message
, which is only included when a report is sent as an attachment as would be the case if the report was generated as a PDF document, is "A report has been generated and sent to you", and can be changed by setting the message
property or by setting the report.email.message
i18n resource value.
Code Block |
---|
| xml |
---|
| xml |
---|
title | Setting subject and messagexml |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:com.cohga.server.config#1.0" xmlns:report="urn:com.cohga.server.report#1.0">
<report:email id="feedback">
<from>noreply@sforbes.net</from>
<to>feedback@sforbes.net</to>
<subject>Feedback</subject>
<message>The following has been submitted as a feedback report</message>
</report:email>
</config>
|
Code Block |
---|
| xml |
---|
| xml |
---|
title | Setting subject and message using i18n resources | xml |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="urn:com.cohga.server.config#1.0" xmlns:report="urn:com.cohga.server.report#1.0" xmlns:client="urn:com.cohga.html.client#1.0">
<client:resources>
<resource id="report.email.subject">Feedback</resource>
<resource id="report.email.message">The following has been submitted as a feedback report</resource>
</client:resources>
<client:resources lang="it">
<resource id="report.email.subject">Retroazione</resource>
<resource id="report.email.message">È stata presentata la seguente come un rapporto di feedback</resource>
</client:resources>
<report:email id="feedback">
<from>noreply@sforbes.net</from>
<to>feedback@sforbes.net</to>
</report:email>
</config>
|
...
One the smtp server and email configuration has been setup it's just a matter of referencing the email config in a simple report action or menu
Code Block |
---|
| xml |
---|
| xml |
---|
title | Simple report action to email a reportxml |
---|
|
<item action="com.cohga.client.action.simplereport">
<email>feedback</email>
<format>html</format>
<report>br_map</report>
<label>Feedback</label>
<tooltip>
<title>Feedback</title>
<text>Send a feedback report using the current map</text>
</tooltip>
</item>
|
The above report item will email the br_map
report in HTML format directly to the user listed in the feedback email config.
If the report has any parameters then the user will be asked to enter the parameters before the report is sent, but if the report doesn't have any parameters then the report will be sent straight away.
Similarly, because the report config specifies a format that format will be used and the user not asked to pick a particular format, but if the format wasn't included the user would be asked to select the format before the report was emailed.
Code Block |
---|
| xml |
---|
| xml |
---|
title | Specifying email properties directly in the report action | xml |
---|
|
<item action="com.cohga.client.action.simplereport">
<email>
<from>${userid}@sforbes.net</from>
<to>feedback@sforbes.net</from>
</email>
<format>html</format>
<report>br_map</report>
<label>Feedback</label>
<tooltip>
<title>Feedback</title>
<text>Send a feedback report using the current map</text>
</tooltip>
</item>
|
The above example does not require the email
config at all, the values are directly set in the report action, using the default values for those properties that are not set.
Code Block |
---|
| xml |
---|
| xml |
---|
title | Extending email propertiesxml |
---|
|
<item action="com.cohga.client.action.simplereport">
<email id="feedback">
<from>${userid}@sforbes.net</from>
<to>feedback@sforbes.net</from>
</email>
<format>html</format>
<report>br_map</report>
<label>Feedback</label>
<tooltip>
<title>Feedback</title>
<text>Send a feedback report using the current map</text>
</tooltip>
</item>
|
...