Answers.Body: <p>You can do this by <a href="https://craftcms.com/docs/3.x/config/#mailer-component" rel="nofollow noreferrer">overriding <code>fromName</code> and <code>fromEmail</code> in the mailer component config</a> based on your site handle (or language).</p>
  <p>You would do this in your <code>config/app.php</code> like so:</p>
  <pre class="lang-php prettyprint-override"><code>'components' =&gt; [
      'mailer' =&gt; function() {
          // Fetch the site the user is on
          $currentSiteLanguage = Craft::$app-&gt;getSites()-&gt;currentSite-&gt;handle;
  
          // Fetch the stored email settings
          $settings = craft\helpers\App::mailSettings();
  
          // Define the name and email address based on language. Change `public` to match your own site handle
          $fromName = $currentSiteLanguage == 'public' ? 'From your public site' : 'Default from name';
  
          $fromEmail = $currentSiteLanguage == 'public' ? 'email@public.site' : 'default@email.address';
  
          // Apply the name to existing settings
          $settings-&gt;fromName = $fromName;
  
          // Apply the name to existing settings
          $settings-&gt;fromEmail = $fromEmail;
  
          // Create a Mailer component config with these settings
          $config = craft\helpers\App::mailerConfig($settings);
  
          // Instantiate and return it
          return Craft::createObject($config);
      },
  ],
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-01T12:52:00.143Z
Answers.LastActivityDate: 2021-03-01T12:52:00.143Z
Answers.UserDisplayName: Oli
Body: <p>I have several sites running under one Craft install. Two of them are for our internal use, and one is public-facing. On the public-facing site, I need to provide a reset password function. When the email is generated to the user, it looks like this:</p>
  <blockquote>
  <p>{Name of primary site} info@primarysite.com
  Wed 2/24/2021 1:13 PM
  Hey Ben,
  To reset your {name of primary site} password, click on this link:
  https://<strong>public-facing-site.edu</strong>/admin/set-password?code=nwKE16ULcdBfj30IDhfZWz4IOjlhkkjlf8hi75fi87aw5f8o75of757i8</p>
  </blockquote>
  <p>Is it possible to customize this email to reflect the site which the user has accessed? Note that the domain name part of the password reset URL is the correct public-facing one. I see the area <strong>Utilities &gt; System Messages</strong> where I can customize this, but the email still includes reference to the primary site.</p>
  
Tags: <users><password>
Title: Change password messaging per site?
ThreadText: # Change password messaging per site?
  
  (Asked by: username_0 on 2021-02-24)
  
  I have several sites running under one Craft install. Two of them are for our internal use, and one is public-facing. On the public-facing site, I need to provide a reset password function. When the email is generated to the user, it looks like this:
  
  > {Name of primary site} info@primarysite.com
  > Wed 2/24/2021 1:13 PM
  > Hey Ben,
  > To reset your {name of primary site} password, click on this link:
  > https://**public-facing-site.edu**/admin/set-password?code=nwKE16ULcdBfj30IDhfZWz4IOjlhkkjlf8hi75fi87aw5f8o75of757i8
  
  Is it possible to customize this email to reflect the site which the user has accessed? Note that the domain name part of the password reset URL is the correct public-facing one. I see the area **Utilities > System Messages** where I can customize this, but the email still includes reference to the primary site.
  
  **Tags:** users, password
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-01. Score: 2 | Accepted answer
  
  You can do this by [overriding `fromName` and `fromEmail` in the mailer component config](https://craftcms.com/docs/3.x/config/#mailer-component) based on your site handle (or language).
  
  You would do this in your `config/app.php` like so:
  
  ```php
  'components' => [
      'mailer' => function() {
          // Fetch the site the user is on
          $currentSiteLanguage = Craft::$app->getSites()->currentSite->handle;
  
          // Fetch the stored email settings
          $settings = craft\helpers\App::mailSettings();
  
          // Define the name and email address based on language. Change `public` to match your own site handle
          $fromName = $currentSiteLanguage == 'public' ? 'From your public site' : 'Default from name';
  
          $fromEmail = $currentSiteLanguage == 'public' ? 'email@public.site' : 'default@email.address';
  
          // Apply the name to existing settings
          $settings->fromName = $fromName;
  
          // Apply the name to existing settings
          $settings->fromEmail = $fromEmail;
  
          // Create a Mailer component config with these settings
          $config = craft\helpers\App::mailerConfig($settings);
  
          // Instantiate and return it
          return Craft::createObject($config);
      },
  ],
  
  ```
  
  
  ---
  
  