Level 11
Hello,
You can set environment variables at runtime using Laravel's config() helper function documented in https://laravel.com/docs/7.x/configuration#accessing-configuration-values
For your use case, I think you can retrieve whatever the port value is from your database and set your app to use it at runtime this way:
$portValue = $retrieveFromDatabase // retrieve this value from your database
config(['mail.port' => $portValue);