laravel-verification-code icon indicating copy to clipboard operation
laravel-verification-code copied to clipboard

VerificationCode::send() dosen't send any email neither does it give any error after upgrading from NextApps to Wotz pacakge.

Open ItzDeadShot opened this issue 1 year ago • 2 comments

I have an issue where VerificationCode::send() does not send any email since I upgraded from NextApps to Wotz. The SMTP setting is working with Mailtrap as I have tested by sending an email with out using the laravel-verification-code package.

My PHP version: PHP 8.3.12 (cli) (built: Sep 24 2024 18:08:04) (NTS)

Composer File: "require": { "php": "^8.1", "doctrine/dbal": "^3.7", "guzzlehttp/guzzle": "^7.2", "laravel-json-api/laravel": "^3.2", "laravel/cashier": "^15.4", "laravel/framework": "^10.10", "laravel/sanctum": "^3.3", "laravel/tinker": "^2.8", "mailjet/laravel-mailjet": "^3.0", "spatie/laravel-permission": "^5.11", "spatie/laravel-stripe-webhooks": "^3.6", "stripe/stripe-php": "^13.7", "symfony/http-client": "^6.4", "wotz/laravel-verification-code": "^3.0" }, "require-dev": { "fakerphp/faker": "^1.9.1", "laravel-json-api/testing": "^2.1", "laravel/pint": "^1.0", "laravel/sail": "^1.18", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", "phpunit/phpunit": "^10.1", "spatie/laravel-ignition": "^2.0" },

ItzDeadShot avatar Nov 26 '24 07:11 ItzDeadShot

any error?

noxsii avatar Mar 19 '25 18:03 noxsii

@ItzDeadShot a custom notification helped me. Without ShouldQueue

<?php

namespace App\Modules\Users\Notifications;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Wotz\VerificationCode\Notifications\VerificationCodeCreatedInterface;

class VerificationCodeCreated extends Notification implements VerificationCodeCreatedInterface
{
    public $code;

    public function __construct(string $code)
    {
        $this->code = $code;
    }

    public function via(): array
    {
        return ['mail'];
    }

    public function toMail(): MailMessage
    {
        return (new MailMessage())
            ->subject(__('Your verification code'))
            ->greeting(__('Hello!'))
            ->line(__('Your verification code: :code', ['code' => $this->code]))
            ->line(__('Kind regards'));
    }
}

zabavnikov avatar Jun 08 '25 05:06 zabavnikov