Package: collective.contentrules.mailfromfield
ContentsIntroductionHow to useHow it take the email dataWhat it try to readMessage interpolationA real Plone use caseTODORequirementsCreditsAuthorsChangelog1.2.1 (2023-06-20)1.2.0 (2023-06-19)1.1.0 (2023-06-19)1.0.1 (2021-03-10)1.0.0 (2020-11-23)0.4.0 (2015-03-13)0.3.0 (2014-05-06)0.2.0 (2013-05-02)0.1.0 (2011-10-21)IntroductionThis product will add to Plone a new content rules, someway similar to the default “Send an email” ones.
The difference is that the email recipient is taken dinamically from a site content, not from a
static list of values.In this way the same rule, applied in different places in the site, can send the message to different users.How to useThe rules can be enabled globally and locally like every one else, as default Plone feature.
In the rule configuration panel you need to fill a set of information:SubjectThe e-mail subject. You can place inside this text some markers (see below).Sender emailThe sender of the e-mail. You can leave this empty and automatically use the one from the
general mail settings.Source fieldYou must put there the name of the attribute from which you want to retrieve the recipient
e-mail. See next section.Target elementYou need to select if the recipient’s e-mail must be taken from:the container where the rules is activated onthe content who notified the event that started the rule executionthe parent of that contentSee below for details.Mail messageThe body text of the e-mail that will be sent. The text is the same for all section where
the rule is activated on.You can place inside this text some markers (see below).How it take the email dataFirst of all you must choose theTarget element.If you choose to keep default “From rule’s container” option address will be read from the section you have
activated the rule on.Example: if you activated the rule on folder/site/sectionand the rule will raise event when
working on a document/site/section/folder/foothe email address will be taken
from the folder.Changing to “From content that triggered the event” will change the behavior, trying to get email data
from the content that raised the event.Example: if you activated the rule on a folder/site/sectionand the rule  will raise event when
working on a document/site/section/folder/foothe email address will be taken
from thefoodocument.Finally, if you choose “From content’s parent”, adresses will the taken from the container of the content
that triggered the event.Example: if you activated the rule on a folder/site/sectionand the rule  will raise event when
working on a document/site/section/folder/foothe email address will be taken
fromfolder.What it try to readThe rule try to get from the object:an attribute of the given namea callable method from the given namean Archetypes field with given ida ZMI property with given idThe rule try to read, one after one, all this data. The first match found will be the one used;
if not one give results, no e-mail is sent at all.Message interpolationMarker labels that follow can be used in the message text and subject.${title}The title of the content that triggered the event (footitle in our example)${url}The URL of the content that triggered the event (fooURL in our example)${section_name}The title of the folder where the rule is activated on (sectiontitle in our example)${section_url}The URL of the folder where the rule is activated on (sectionURL in our example)A real Plone use caseA Plone site useSignup Sheetfor manage internal training session. The form fieldset is
customized as normal, but one of the field isdirector_email.We want that this e-mail address is notified when a user subscribe and the user
itself put there the e-mail address of the proper director.To reach this we need to:create a new rule triggered on “Object added to this container”add a filter condition based on content typeRegistrantadd an action using the “Send email to address taken from the content”specify in the action the SignupSheet field with the director emailspecify in the action that we want to take the email from the target content
(the Registrant itself)TODOwhy don’t support also looking in annotations?right now the rules check all mail source until one is found with a defined order;
maybe is better to leave this choice to the configurationDexterity support (probably already there, but needs to be tested)RequirementsThis product has been tested on:Plone 4.2 with 0.4 versionPlone 4.3 with 0.4 versionPlone 5.0Plone 5.1CreditsDeveloped with the support ofS. Anna Hospital, Ferrara; S. Anna Hospital supports thePloneGov initiative.This product was largely developed looking at the source ofcollective.contentrules.mailtogroup.AuthorsThis product was developed by RedTurtle Technology team.Changelog1.2.1 (2023-06-20)send email on successful transaction commit (#9)
[mamico]1.2.0 (2023-06-19)Change mail send method and allow to eventually add attachments.
[cekk]1.1.0 (2023-06-19)Plone 6 support
[foxtrot-dfm1]1.0.1 (2021-03-10)Allow to get to the end of the action execution if no mail is provided.
You don’t want the page to break if the email is missing.
For the anonymous user this wold be a bad UX
[lucabel]1.0.0 (2020-11-23)Migrate code to Plone 5/python 3.
[lucabel]Add support for plone.stringinterp.
[cekk]0.4.0 (2015-03-13)Dropped Plone 3 compatibilityFixed some label that were not i18n compatible
[keul]Fixed wrong documentation mess introduced on version 0.3:
the new “parent” option was wrongly descripted
[keul]Updated documentation to reflect changes done in version 0.3
[keul]0.3.0 (2014-05-06)Fix unicode error while replacing strings [nicolasenno]Do not fail if a rule is activated on a non-AT content [keul]Do not try to send mail to empty string recipients [keul]Refactoring [alert]Added parent option in the target vocabulary [alert]0.2.0 (2013-05-02)lowered logging level to debug
[keul]fixed ruleAction factory
[cekk]0.1.0 (2011-10-21)Initial release