Try to use Rules module or Rules API for feature like sending mail based on any event

Problem Statement: Recently, in my project, I came across a situation where on a webform submit by the authenticated user I had to send mail based on a configured variable. So, the condition was if variable is set to value 1 mail should be sent to site admin, else if it is configured 2 mail should be sent to the users which were referenced from the current user via field (say field_user_references) and tricky part if user field (field_user_references) is empty, mail should go to the site admin only.

Now, first obvious, easy and probably perfect solution comes to the mind is custom. Let's make a form alter and add our custom submit handler and play with the code to achieve functionality, quite easy!!!

But, what if we achieve this via Rules module.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.