I'm trying to build a simple ticketing system with Drupal 8.6. I'm able to create a content type for these tickets and the comments will be the responses to the ticket. Also I have a status field for open, pending, and closed. I want to be able to email all the users on the ticket if the node is updated or commented on. And I have another user reference field for "assigned ticket to".

What modules would I need that work with 8.6 to get this kind of funtionality? I prefer no modules, but I'm not sure if core itself supports this type of thing.


I recently did something similar, for reacting when the node is updated i used hook_node_presave(). Here's an example on how to send an email when the node is updated and the status is changed from "open" to "pending".

function my_module_node_presave(NodeInterface $node){
  if($node->getType() == 'your_content_type_name' AND $node->isNew() == FALSE) {
   $status_original = $node->original->get('status_field')->value;
   $status_updated = $node->get('status_field')->value;

 if ($status_original !== $status_updated AND $status_original == 'open' AND $status_updated == 'pending') {

For creating the send_mail function or whatever you'd like to call it i used the following resource and modified the code where necessary: How to send a mail programmatically in Drupal 8. Also, i used the SMTP Authentication Support module to send the emails using a gmail account: SMTP Authentication Support. The configuration page of the module is on admin/config/system/smtp.

For checking if a comment has been posted you can use hook_ENTITY_TYPE_insert() and replace "ENTITY_TYPE" with "comment" and inside the hook you can call again the send_mail function.

I did not quite understood how you are storing "all the users on the ticket", but it would be the case of getting the users email address with getEmail();

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.