Kirby March 18, 2025

Navigating Kirby: User Management and Email Configuration

Ivo Jerković
Ivo Jerković
Author

Introduction

About six months ago, I discovered Kirby as a lightweight alternative to WordPress and decided to build a website using this platform. My progress was steady, learning and implementing features as I went along. Recently, after a long pause, I resumed work on the site, focusing on completing the remaining tasks, including setting up a contact form. However, this seemingly simple task led me to explore Kirby's user management and email configuration.

Resuming the Project

I initiated my Kirby local environment using the command php -S localhost:8000 kirby/router.php, which starts the website at localhost:8000. Upon attempting to log in to the panel, I realized I had forgotten the password. Since localhost:8000 is used for various purposes, the stored password was incorrect.

Password Reset Configuration

To resolve this, I needed to enable the password reset feature by adding a few lines to the site/config/config.php file:

return [
    'auth' => [
        'methods' => ['password', 'password-reset']
    ]
];

Kirby Documentation: Password Reset Form

After requesting a password reset, I encountered another issue: the email wasn't sent because I hadn't configured any email options for my localhost environment. I had two choices: set up a real SMTP provider or use Mailhog to mock SMTP. Since I already had Mailhog installed, I opted for the latter. Configuring Kirby to use Mailhog is simple; just add the following lines to the site/config/config.php file:

'email' => [
    'transport' => [
        'type' => 'smtp',
        'host' => 'localhost',
        'port' => 1025,
        'security' => false,
    ]
],

Kirby Documentation: Using Mailhog for Email Testing

Resolving Email Errors

Upon attempting the password reset again, I found that Mailhog was empty, and the error logs indicated that "noreply@localhost is not a valid email address." This issue was not unique, as discussed on the Kirby forum.

Kirby uses a default email address, noreply@domainname, for password reset emails. Since I was running on localhost, the generated email wasn't valid, preventing the password reset email from being sent. Adding a from email address to the auth.challenge.email.from configuration resolved the issue. This email doesn't need to be real since we're not sending anything externally:

'auth' => [
    'methods' => ['password', 'password-reset'],
    'challenge' => [
        'email' => [
            'from' => 'ivo@ivo.com'
        ]
    ]
],

Conclusion

What started as a simple task of setting up a contact form turned into a practical exploration of Kirby's user management and email configuration. While these tasks were relatively basic, they provided valuable insights into Kirby's capabilities and prepared me for future challenges. This experience underscores the importance of understanding the fundamentals, even when tackling seemingly straightforward tasks.

Stay tuned for more insights into web development with Kirby.

#Kirby