I need to theme emails that happen when a user completes a booking on our site or modifies there booking after this. Is there a way I can resend emails that Drupal has already sent? This would greatly speed things up for me not having to make new or edit existing bookings.

  • It would help if you also tell what modules you are using to accomplish the bookings. Also, Drupal does not save emails unless you use a logging module like Maillog. So you are going to have to regen the emails another way. – Brady Feb 25 '16 at 17:05

Step 1: Create a view of all these bookings

First think of a way to create a view (using the Views module) of all those bookings for which you want to resend such eMails.

Step 2: Create a Rules component for sending an eMail

Create a Rules Component that will be used in Step 3 to actually send your eMail. Here is an example of such Rules Component to be created:

{ "rules_send_booking_email" : {
    "LABEL" : "Send Booking eMail",
    "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" : "Some information about your booking",
          "message" : "This is an update about your booking with reference [user-to-notify:field_about_some_booking] ...",
          "from" : "[site:mail]",
          "language" : [ "" ]

It uses (references) some field that was added to the "user" entity with machine name (say) field_about_some_booking. Feel free to adapt to any field name you have available. And/or use some other entity (eg a node about a booking?), instead of "user", to which this field might be related to. If you want, you can just import the above Rules Component (in Rules export format) in your own environment (via copy-paste), but make sure the machine name of the field matches with what you have available (otherwise the import will fail).

Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.

Step 3: Get VBO involved to actually trigger all the eMails

Transform the view from Step 1 into a Views Bulk Operations (=VBO) view. And have the actual VBO "operation" execute the Rules Component that you created in Step 2.

If you're not familiar with how to do so, have a look at the video about Using Rules components with VBO". If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: the size (volume) that needs to be processed might be another (extra) challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

Happy VBO-ing while Rules-ing!

| 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.