Set custom headers to Accounts sendenrolmentemail


#1

hi
i need to set custom headers for every enrollment email i send with Accoounts.
this is how i did it:
var previousHeaders = Accounts.emailTemplates.headers;
Accounts.emailTemplates.headers = {‘X-Mailgun-Variables’: JSON.stringify({ programId: programId, applicantId: applicant._id }) };
Accounts.sendEnrollmentEmail(applicantUserId);
Accounts.emailTemplates.headers = previousHeaders;

is there any other way to do this?
is there guarantee that this code will run synchronously? in case of many enrollments i might run over headers because it is global.

thanks