How can I pass variables to email's template onBeforeSendEmail I'm trying to add some variables to email's template to be rendered before email is sent.

I was able to modify emailModel like customHeaders and subject but I couldn't pass custom variables to the template.

How can I pass variables to email's template using onBeforeSendEmail event?
I don't know if this is the same kind of thing you are looking for, but I think it's close.

I created a plugin that handles a contact form submission. When the user fills out the form, an email is sent to me &amp; the person who filled out the form. I'm not listening to onBeforeSendEmail, but rather listening for a save event that I call via controller.

I told Craft that I needed a settings area in my plugin, then I created a textarea where I could manage the email that was sent to the user(s). This is what that looks like:

&lt;p&gt;Hi {{firstName}} &amp;mdash; thank you for reaching out to us!&lt;br&gt;We wanted to drop you a quick note that we've received your information and we'll be in touch very soon!&lt;/p&gt;&lt;p&gt;Regards,&lt;br&gt;The friendly folks at this website&lt;/p&gt;


To get {{firstName}} to use the value that were entered in the form, I used this in my plugin's service file.

That way it would read "Hi Steve - thank you for..."

MyPluginService.php

...
$email = new EmailModel();
$email-&gt;fromEmail = $emailSettings['emailAddress']; // set in CP
$email-&gt;replyTo = $emailSettings['emailAddress'];   // set in CP
$email-&gt;sender = $emailSettings['emailAddress'];    // set in CP
$email-&gt;fromName = $emailSettings['senderName'];    // set in CP
$email-&gt;toEmail = $contact-&gt;email;
$email-&gt;subject = $settings-&gt;guestSubject;
$email-&gt;body = craft()-&gt;templates-&gt;renderString($settings-&gt;welcomeEmailMessage, array('firstName' =&gt; $contact-&gt;firstName));

if (craft()-&gt;email-&gt;sendEmail($email)) {
    return true;
}
....


It's the craft()-&gt;templates-&gt;renderString() part that lets me hook into my plugin to set the variable values.

Hope this helps!