Set "from" field in Emails module link to current logued user

Hi

When I create a draft email in any related module, Leads for example, and then  save the draft email, in the from field, sugarCRM sets the current user Link.

I am trying to do the same in a logic hook, but I don't know how to do that. I saw the model in the sidecar and the field name is "from_collection", I try those, but did not work.

global $current_user;
$lead = BeanFactory::retrieveBean("Leads", "5f6172c0-466c-11e9-b85f-02dcb16454fa");
$user = BeanFactory::retrieveBean("Users", $current_user->id);
$mail = BeanFactory::newBean("Emails");
$emailAddres = null;

if($user->load_relationship("email_addresses"))
{
$emailAddres = $user->email_addresses->getBeans();
$emailAddres = $emailAddres[array_keys($emailAddres)[0]];
}

$mail->assigned_user_id = $user->id;
$mail->parent_type = "Leads";
$mail->parent_id = "5f6172c0-466c-11e9-b85f-02dcb16454fa";

//firts try
$mail->from_addr = $user->email1;
$mail->from_name = $user->name;
//second try
$mail->from_collection = $user;
//third
$mail->from = $user;

I saw the Email class in sugar and it says

/**
* The name and email address of the email's sender, formatted for use in the email's FROM header.
*
* @var string
* @deprecated Use {@link Email::$from} to link the sender to the email.
*/
    var $from_addr;

any Idea how to use @link Email::$from