How do I get an article's author email programmatically? I would like to send an email to authors when their content updated. How can I get the email of author(s)?

I think $to = \Drupal::currentUser()-&gt;get('mail'); is not my friend.
Since you are talking of authors, I take you are referring to users who posted a node. In that case, supposing you have a $node variable, you should use the following code.

use \Drupal\node\Entity\Node;
use \Drupal\user\UserInterface;

/** @var \Drupal\user\UserInterface $user */
$user = $node-&gt;getOwner();
$email = $user-&gt;getEmail();


If, instead, you are trying to get the email of the currently logged-in user, then you cannot use \Drupal::currentUser()-&gt;get('mail') because \Drupal::currentUser() returns an object implementing \Drupal\Core\Session\AccountProxyInterface, which doesn't have any get() method.

If you want the email associated with the account, you need to use the following code.

use \Drupal\Core\Session\AccountProxyInterface;

/** @var \Drupal\Core\Session\AccountProxyInterface $user */
$user = \Drupal::currentUser();
$email = $user-&gt;getEmail();


If then you would need a User object, you should use the following code.

use \Drupal\Core\Session\AccountProxyInterface;
use \Drupal\user\Entity\User;

/** @var \Drupal\user\Entity\User $user */
$user = User::load(\Drupal::currentUser()-&gt;id());