cachet icon indicating copy to clipboard operation
cachet copied to clipboard

Email settings can't be changed

Open gcommit opened this issue 4 years ago • 7 comments

Hello,

when i setup a Cachet and enter my Mailserver data, after finishing the process, the data is reset to default like "localhost"

If i once again change the data in the settings section and press "Save" it is again reset to default.

What can i do?

Best regards

gcommit avatar Apr 09 '21 07:04 gcommit

Hi, are you sure you're hitting save? I also have this reset problem, but only when I hit the Test button.

pavog avatar Apr 09 '21 09:04 pavog

I think i can read. The Button with "Save" on it, is the right one, yes?

Of course i am hitting the Save button....

gcommit avatar Apr 09 '21 10:04 gcommit

I'm sorry if that sounded impolite. I didn't mean to offend you.

I just wasn't sure because I couldn't reproduce the problem. I only had the problem when I pressed the test button.

Now I have found the mistake on my side: After I entered the values and pressed save, I had to reload the page. Now I see the same result as you described.

It looks like the problem exists when you reload the page. After pressing the test button, the page is reloaded. That's why I only got the result when I pressed the save button.

I have already found out the following:

  • When saving, a POST request is sent to dashboard/settings/mail.
  • This executes SettingsController.php::postMail
  • This creates the UpdateConfigCommand
  • The UpdateConfigCommand is executed by the UpdateConfigCommandHandler.
  • The UpdateConfigCommandHandler writes the values from the request into the env file
  • The values for the email settings are not loaded from the env file

pavog avatar Apr 09 '21 12:04 pavog

I have found out that it is a cache error. The configuration is in the cache, as is the configuration for the emails. Simply writing to the .env file is not enough. It must also be reloaded / the cache must be cleared.

I suggest something like:

// Clears the cached config like artisan config:clear does.
if (app()->configurationIsCached()) {
    $this->files->delete(app()->getCachedConfigPath());
}

After writing to the env file in the UpdateConfigCommandHandler.

Note: $this->files is \Illuminate\Filesystem\Filesystem

pavog avatar Apr 09 '21 12:04 pavog

Yes. When i write it to the .env file and restart Cachet, it is shown in the Admin Webinterface. But NEVER when i change something in the Admin Webinterface, it is written to the .env file

gcommit avatar Apr 12 '21 09:04 gcommit

I have found out that it is a cache error. The configuration is in the cache, as is the configuration for the emails. Simply writing to the .env file is not enough. It must also be reloaded / the cache must be cleared.

I suggest something like:

// Clears the cached config like artisan config:clear does.
if (app()->configurationIsCached()) {
    $this->files->delete(app()->getCachedConfigPath());
}

After writing to the env file in the UpdateConfigCommandHandler.

Note: $this->files is \Illuminate\Filesystem\Filesystem

Hi I also encountered the same issue using cachet-docker installation. Where should I put that fix you mentioned?

lnfel avatar Jul 05 '22 02:07 lnfel

UpdateConfigCommandHandler

UpdateConfigCommandHandler.php

pavog avatar Jul 05 '22 13:07 pavog

Thank you for your input on Cachet 2.x. We are shifting our attention and resources to Cachet 3.x and will no longer be supporting the 2.x version. If your feedback or issue is relevant to the 3.x series, we encourage you to engage with the new branch.

For more information on the Cachet rebuild and our plans for 3.x, you can read the announcement here.

We appreciate your understanding and look forward to your contributions to the new version.

jbrooksuk avatar Aug 12 '23 19:08 jbrooksuk