File: /home/lesanew/anestetues2/web/app/mu-plugins/mailpit-smtp.php
<?php
/**
* Configure l'envoi d'emails via Mailpit en développement.
*/
add_action('phpmailer_init', function ($phpmailer) {
if (! function_exists('env')) {
return;
}
$host = env('MAIL_HOST', '127.0.0.1');
$port = (int) env('MAIL_PORT', 1025);
$username = env('MAIL_USERNAME');
$password = env('MAIL_PASSWORD');
$encryption = env('MAIL_ENCRYPTION');
if (empty($host) || empty($port)) {
return;
}
$phpmailer->isSMTP();
$phpmailer->Host = $host;
$phpmailer->Port = $port;
$phpmailer->SMTPAuth = ! empty($username) && ! empty($password);
$phpmailer->Username = $username ?: null;
$phpmailer->Password = $password ?: null;
$phpmailer->SMTPSecure = $encryption ?: null;
});