<?php
// Register SMTP email with HTML support.

// add_action('phpmailer_init', 'krik_set_smtp');
// add_filter('wp_mail_content_type', fn () => 'text/html');
// add_filter('wp_mail_from_name', fn () => env('MAIL_FROM_NAME', 'Example'));
// add_filter('wp_mail_from', fn () => env('MAIL_FROM_ADDRESS', 'hello@example.com'));

function krik_set_smtp(PHPMailer $mail)
{
    $mail->isSMTP();
    $mail->SMTPAutoTLS = false;
    $mail->SMTPAuth = env('MAIL_USERNAME') && env('MAIL_PASSWORD');
    $mail->SMTPSecure = env('MAIL_ENCRYPTION', 'tls');
    $mail->Host = env('MAIL_HOST');
    $mail->Port = env('MAIL_PORT', 587);
    $mail->Username = env('MAIL_USERNAME');
    $mail->Password = env('MAIL_PASSWORD');
    return $mail;
}
