Skip to content

SMTP connection check? #153

Answered by vlados
vlados asked this question in Q&A
Jan 28, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

This is my solution:

<?php

namespace App\Checks;

use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;

class MailCheck extends Check
{
    public function run(): Result
    {
        $this->label = 'Mail ('.config('mail.default').')';

        switch (config('mail.default')) {
            case 'smtp':
                return $this->checkSmtp();

            default:
                $result = Result::make();

                return $result->failed('Mailer '.config('mail.default').' is not supported');
        }
    }

    private function checkSmtp(): Result
    {
        $result = Result::make();

        try {
     …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Saifallak
Comment options

Answer selected by vlados
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants