We were assigning variants in a controller, in the context of a request. However, when sending emails, there is no request and no controller is involved, so we also need to set the variant in the ApplicationMailer class.