I would like to send an automatic email once a person is 15 days before leaving the department (which means when the “visit to” field of the “Profile” content type is equal to today - 15 days). I tried to implement it with the Rules, but I don’t think it’s possible. Could you suggest me any other easy way?
Otherwise, could you give me some instructions on how I can implement it with a custom module? For example: which function (and when) do I need to trigger in order to make a query inside profiles?
Why you say it doesn’t work with Rules? Did you try it? What was the result?
An alternative would be to write a Drupal module that implements hook_cron (example). Then every time that Cron runs on your website you will check in all the nodes of content type Profile the visit_to field and if there are 15 days left then the system will send an email. You can create and send the email programmatically. For more info on how to do this see the links below: