giorg
7 months ago

config change at runtime for custom smtp

Posted 7 months ago by giorg

Hello, I need to send email using different smtp, so I'm trying to change .env data at runtime. This is what I've done so far:

$_ENV['MAIL_HOST'] = $smtp; $_ENV['MAIL_PORT'] = $smtp_port; $_ENV['MAIL_USERNAME'] = $address; $_ENV['MAIL_PASSWORD'] = $password; if ($ssl === '1') { $_ENV['MAIL_ENCRYPTION'] = 'tls'; }

but I receive

Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required

but if I write the values of those variables directly in the .env, it works like a charm.

Any hint? thanks a lot

Please sign in or create an account to participate in this conversation.