Part 1 - Rules Component to send an eMail
Here is a Rules Component (in Rules export format) to send an eMail to a user indicated as a parameter of the Rules Component (adapt the subject and eMail body to your own needs):
{ "rules_send_email_notification" : {
"LABEL" : "Send eMail notification",
"PLUGIN" : "action set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
"ACTION SET" : [
{ "mail" : {
"to" : [ "user-to-notify:mail" ],
"subject" : "Your eMail subject goes here ...",
"message" : "Your message body goes here ...",
"from" : "[site:mail]",
"language" : [ "" ]
}
}
]
}
}
Part 2 - Rule to trigger the Rules Component
Here is the rule (in Rules export format) to execute the Rules Component from Part 1 (adapt the machine name of the flag you're using prior to importing it in your own site):
{ "rules_send_email_to_author_of_a_flagged_node" : {
"LABEL" : "Send eMail to author of a flagged node",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "flag" ],
"ON" : { "flag_flagged_playlist_confirmation" : [] },
"DO" : [
{ "component_rules_send_email_notification" : { "user_to_notify" : [ "flagged-node:author" ] } }
]
}
}
This rule gets triggered (Rules Event) when a node is flagged with a flag that has machine name playlist_confirmation
. Note the value of the parameter passed to the Rules Component, i.e. flagged-node:author
(the author of the node being flagged). Obviously, you want to limit access to this flag to users like your admin only.
That's really it.
PS: you don't really need to use a Rules Component, since you could "integrate" (hardcode) what the Rules Component does in your actual rule also. So that's rather a matter of coding style. If you'd make your eMail subject and message body another parameter for the Rules Component, you can re-use that Rules Component for all sorts of eMails you want to send via Rules. And if some day you'd want to replace sending eMails (by Rules) by using the (amazing) Message module, you'd only have to adapt your Rules Component for it.