Skip to content

Commit

Permalink
Merge branch 'master' into acl-content-groups
Browse files Browse the repository at this point in the history
Conflicts:
	modules/mod_menu/templates/text/_menu_edit_scripts.tpl
	modules/mod_search/support/search_query.erl
  • Loading branch information
mworrell committed Jun 25, 2015
2 parents b28c9fb + 3dcd0e7 commit 062a7e4
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 37 deletions.
84 changes: 59 additions & 25 deletions doc/manuals/email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Site-specific settings
|site |email_override |If set, all e-mail messages that get sent|
| | |from Zotonic will arrive at this |
| | |address. Useful if you are testing but |
| | |don't want to confuse other people with |
| | |dont want to confuse other people with |
| | |your test e-mails. |
+----------+----------------------+-----------------------------------------+
|site |smtphost |The hostname where you want messages to |
Expand All @@ -61,6 +61,9 @@ places for determining the admin e-mail address: the config key
``zotonic.admin_email``, then the ``site.admin_email`` key, and
finally the `email` property of the admin user (user with id 1).

If no admin email address is found then the address ``wwwadmin@example.com``
is used, where ``example.com`` will be your site’s hostname.


Zotonic-wide settings
.....................
Expand All @@ -69,19 +72,16 @@ The file ``~/.zotonic/zotonic.config`` can be configured to hold any of the
configuration options below. They are in effect for every site running
in the Zotonic instance.

Zotonic-wide settings for receiving email
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

+--------------------------+--------------------------------------+
|Key |Description |
+==========================+======================================+
|smtp_relay |Whether or not to use a SMTP relay |
| |host. Boolean value, defaults to |
| |false. |
+--------------------------+--------------------------------------+
|smtp_relay_host |Host name for the relay server. |
| |Defaults to "localhost". |
+--------------------------+--------------------------------------+
|smtp_relay_port |Port number of the SMTP relay host. |
| |Defaults to 2525. |
+--------------------------+--------------------------------------+
|smtp_host |The hostname for the SMTP relay host, |
| |only needed if smtp_relay is enabled. |
+--------------------------+--------------------------------------+
Expand All @@ -107,21 +107,48 @@ in the Zotonic instance.
|email_override |A global e-mail override. The override|
| |logic first checks the site override, |
| |and then the global override address. |
+--------------------------+--------------------------------------+
|smtp_spamd_ip |Optional IP address for a spamassassin|
| |host |
+--------------------------+--------------------------------------+
|smtp_spamd_port |Optional port number for a |
| |spamassassin host |
| |Useful for testing and development. |
+--------------------------+--------------------------------------+
|smtp_bounce_domain |Which domain to use for bounce VERP |
| |messages. Defaults to the smtp domain.|
| |messages. Defaults to the smtp domain |
| |of the site sending the email. |
+--------------------------+--------------------------------------+
|smtp_bounce_email_override|The email address for bounce handling.|
| |Only use when all else fails (see |
| |the paragraph below). |
| |Only use if all else fails (see |
| |the paragraphs after the next one). |
+--------------------------+--------------------------------------+

Zotonic-wide settings for receiving email
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To receive email the SMTP server has to listen on the correct IP address and
port. Spam filtering is done by checking DNSBL (DNS Block List) servers and
optionally using Spamassassin.

+--------------------------+--------------------------------------------+
|Key |Description |
+==========================+============================================+
|smtp_listen_domain |The domain announced in the HELO |
+--------------------------+--------------------------------------------+
|smtp_listen_ip |IP address to listen on for incoming |
| |SMTP connections. Defaults to |
| |``"127.0.0.1"`` |
+--------------------------+--------------------------------------------+
|smtp_listen_port |IP address to listen on for incoming |
| |SMTP connections. Defaults to 2525. |
+--------------------------+--------------------------------------------+
|smtp_dnsbl |List for the DNS block lists used for |
| |checking incoming email connections. |
| |Defaults to |
| |``["zen.spamhaus.org","dnsbl.sorbs.net"]`` |
+--------------------------+--------------------------------------------+
|smtp_spamd_ip |Optional IP address for a spamassassin |
| |host |
+--------------------------+--------------------------------------------+
|smtp_spamd_port |Optional port number for a |
| |spamassassin host |
+--------------------------+--------------------------------------------+


The sender’s domain
...................
Expand All @@ -147,7 +174,7 @@ You need a valid domain for this envelope sender address. The part
before the ``@`` is generated by Zotonic and is used for identifying
the original message and recipient when the message bounces.

When the generated part is not acceptable then you can force an envelope
If the generated part is not acceptable then you can force an envelope
address by setting the ``smtp_bounce_email_override`` option. Setting the
bounce/envelop address manually disables Zotonic’s build-in handling of
bounces that happen *after* the e-mail was accepted for delivery by
Expand All @@ -163,13 +190,18 @@ How does Zotonic know the domain?

It checks in order:

- site’s config: ``bounce_email_override`` (you can also set this with the admin config as site.bounce_email_override)
- global ``~/.zotonic/zotonic.config``: ``smtp_bounce_domain`` setting
- site’s config: ``smtphost`` (you can also set this with the admin config as site.smtphost)
- site’s config: ``smtphost``
- site’s config: ``hostname``

The part before the ``@`` is generated by Zotonic itself, for
administration and detection of bounces. A typical sender address on
the envelope looks like: ``noreply+mlcm6godbz2cchtgdvom@example.org``
Any *bounce_email_override* configuration must be a complete email address.
For example: ``bounces@example.org``

If no *bounce_email_override* is used then the part before the ``@`` is
generated by Zotonic itself, for administration and detection of bounces.
A typical sender address on the envelope looks like:
``noreply+mlcm6godbz2cchtgdvom@example.org``


Sending E-mail
Expand All @@ -193,14 +225,16 @@ e-mail from Zotonic code:
|``z_email:send_render/4``|Renders a template and sends it as a HTML message |
| |to a specified recipient. |
+-------------------------+--------------------------------------------------+
|``z_email:send/2`` |Sends an email defined by a ``#email{}`` record. |
+-------------------------+--------------------------------------------------+


Receiving E-mail
----------------

In its default configuration, Zotonic starts an SMTP server on port
2525 for receiving e-mail messages. You can write your own code to
decide what happens when somebody sends e-mail to the system, by
decide what happens if somebody sends e-mail to the system, by
implementing the ``email_received`` notification (see below).

The SMTP server is also used to receive bounce messages from other
Expand All @@ -224,7 +258,7 @@ program, like this::

Then, you should be greeted by Zotonic in the following way::

220 example.com ESMTP Zotonic 0.9.0
220 example.com ESMTP Zotonic 0.13.0

Press ctrl-c to exit.

Expand All @@ -237,7 +271,7 @@ configured to handle this message. It looks at the ``host`` and
``hostalias`` fields in the site’s config file to match the recipient
domain.

When no site matches the e-mails domain, the message is dropped, and a
If no site matches the e-mails domain, the message is dropped, and a
warning logged.

For handling incoming messages in your site, you need a hook in your
Expand All @@ -263,7 +297,7 @@ Zotonic::
Troubleshooting
---------------

Check in the admin the log and smtp log. When a message bounces back
Check in the admin the log and smtp log. If a message bounces back
to the Zotonic SMTP server, you will see errors there. A typical error
looks like this::

Expand Down
1 change: 1 addition & 0 deletions doc/ref/filters/html/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ HTML
../filter_show_media
../filter_striptags
../filter_truncate_html
../filter_update_iframe
../filter_urlize
../filter_without_embedded_media
1 change: 1 addition & 0 deletions doc/ref/filters/strings/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Strings
../filter_capfirst
../filter_center
../filter_insert
../filter_is_valid_email
../filter_length
../filter_ljust
../filter_lower
Expand Down
3 changes: 2 additions & 1 deletion doc/ref/filters/translation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Translation
:glob:

../filter_is_rtl
../filter_language
../filter_language
../filter_trans_filter_filled
2 changes: 1 addition & 1 deletion doc/ref/modules/mod_artwork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Included CSS icons


How to use Material Design icons in your templates
***********************************************
**************************************************

* Include the CSS file: ``{% lib "material-design/css/material-design-iconic-font.min.css" %}``
* Follow the `examples <http://zavoloklom.github.io/material-design-iconic-font/examples.html>`_
Expand Down
27 changes: 27 additions & 0 deletions doc/technotes/site-fsm.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
digraph site_fsm {

disabled -> enabled;
enabled -> start;
enabled -> disabled;

start -> db_connect_check;
db_connect_check -> datamodel_check;
datamodel_check -> supervisor_start;

supervisor_start -> modules_start;
modules_start -> running;

modules_start -> crashed [style=dashed];
supervisor_start -> crashed [style=dashed];

running -> crashed [style=dashed];
running -> stopped;

stopped -> start;

crashed -> retry;
retry -> start [label="timeout"];

db_connect_check -> retry;
datamodel_check -> retry;
}
9 changes: 5 additions & 4 deletions modules/mod_base/lib/js/apps/zotonic-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,12 @@ function z_ajax(options, data)
{
z_start_spinner();
$.ajax({
url: '/postback',
type: 'post',
data: data,
dataType: 'text',
url: '/postback',
type: 'post',
data: data,
dataType: 'text',
contentType: 'text/x-ubf',
async: !z_page_unloading, // Prevents requests from being cancelled during unloading of the page.
success: function(received_data, textStatus)
{
try
Expand Down
7 changes: 7 additions & 0 deletions modules/mod_search/support/search_query.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
expand_object_predicates/2
]).

%% For testing
-export([
expand_object_predicates/2
]).

-include_lib("zotonic.hrl").

-define(SQL_SAFE_REGEXP, "^[0-9a-zA-Z_\.]+$").
Expand Down Expand Up @@ -747,6 +752,8 @@ expand_object_predicates(Bin, Context) when is_binary(Bin) ->
expand_object_predicates(OPs, Context) ->
map_rids(OPs, Context).

map_rids({rsc_list, L}, Context) ->
map_rids(L, Context);
map_rids(L, Context) when is_list(L) ->
[ map_rid(unquot(X),Context) || X <- L, X =/= <<>> ];
map_rids(Id, Context) ->
Expand Down
6 changes: 3 additions & 3 deletions src/support/z_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ default(smtp_relay) -> false;
default(smtp_host) -> "localhost";
default(smtp_port) -> 2525;
default(smtp_ssl) -> false;
default(smtp_bounce_ip) -> "127.0.0.1";
default(smtp_bounce_port) -> 2525;
default(smtp_listen_ip) -> "127.0.0.1";
default(smtp_listen_port) -> 2525;
default(smtp_spamd_port) -> 783;
default(smpt_dsnbl) -> z_email_dnsbl:dnsbl_list();
default(smtp_dnsbl) -> z_email_dnsbl:dnsbl_list();
default(smtp_delete_sent_after) -> 240;
default(inet_backlog) -> 500;
default(inet_acceptor_pool_size) -> 75;
Expand Down
6 changes: 3 additions & 3 deletions src/zotonic_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ init([]) ->
{z_ids, start_link, []},
permanent, 5000, worker, [z_ids]},

%% SMTP gen_servers: one for encoding and sending mails, the other for bounces
%% SMTP gen_servers: one for sending mails, the other for receiving email
SmtpServer = {z_email_server,
{z_email_server, start_link, []},
permanent, 5000, worker, [z_email_server]},

SmtpBounceServer = {z_email_receive_server,
SmtpReceiveServer = {z_email_receive_server,
{z_email_receive_server, start_link, []},
permanent, 5000, worker, [z_email_receive_server]},

Expand All @@ -96,7 +96,7 @@ init([]) ->

Processes = [
Ids,
SmtpServer, SmtpBounceServer,
SmtpServer, SmtpReceiveServer,
FilesSup,
SitesSup,
FSWatchSup| get_extensions()
Expand Down

0 comments on commit 062a7e4

Please sign in to comment.