Change mail_recipients dynamically

Hi! How can I change mail_recipients dynamically based on a custom model record field? I use Magic Forms. I tried various solutions I found but nothing worked. Here is my code:

pages/author.htm

url = "/author/:slug?"
layout = "default"
title = "Single Author Page"

[singleAuthor]

[emptyForm contactForm2]
group = "Contact"
rules[name] = "required"
rules[tel] = "regex: /^\+?[0-9 ]*$/"
rules[email] = "required | email"
rules[message] = "required"
rules[rodo] = "required"
rules_messages[rodo.required] = "Filed required"
rules_messages[name.required] = "Filed required"
rules_messages[tel.required] = "Filed required"
rules_messages[email.required] = "Filed required"
rules_messages[message.required] = "Filed required"
mail_enabled = 1
mail_subject = "Question to the author"
mail_recipients[default@email.com] = "default@email.com"
mail_replyto = "email"
mail_template = "contactForm"
reset_form = 1
inline_errors = "display"
sanitize_data = "htmlspecialchars"
anonymize_ip = "disabled"
recaptcha_enabled = 0
recaptcha_theme = "light"
recaptcha_type = "image"
recaptcha_size = "normal"
emails_date_format = "Y-m-d"
==

{% component 'singleAuthor' %}

singleAuthor component:

{% set author = __SELF__.author %}

{% if author %}

    <h2>{{ author.name }}</h2>
    {{ author.decription | raw }}

    <h3>Contact</h3>
    {% component 'contactForm2' %}
    {# email should be sent to author.mail #}

{% else %}
    <p>{{ 'Author not found' |_ }}</p>
{% endif %}

Try to find the function that sends the email and ovveride it

I think you can supply the data in the component tag, as the properties get evaluated/populated in the 'onFormSubmit` handler.

So something like this might work:

{% set author = __SELF__.author %}

{% if author %}

    <h2>{{ author.name }}</h2>
    {{ author.decription | raw }}

    <h3>Contact</h3>
    {% component 'contactForm2' mail_recipients={author.mail, 'another-recipient@example.com'} %}
    {# email should be sent to author.mail #}

{% else %}
    <p>{{ 'Author not found' |_ }}</p>
{% endif %}