October: Mail::queueOn & Mail::laterOn Type error

Created on 22 Sep 2017  路  13Comments  路  Source: octobercms/october

Expected behavior

When using Mail::queueOn we should be able to select which queue mail will be queued in but for some reason it does not work. Same error with Mail::laterOn.

Actual behavior

When using Mail::queueOn or Mail::laterOn I am getting this error. Works fine with Mail::queue and Mail::later

"Type error: Argument 2 passed to Illuminate\Mail\Mailable::view() must be of the type array, string given, called in /home/vagrant/website/vendor/october/rain/src/Mail/Mailer.php on line 194" on line 595 of /home/vagrant/website/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php

Reproduce steps

Example of my code

Mail::queueOn('artwork-enquiry', 'ya.profile:mail.artwork_enquiry', $data,  function ($message) use($user) {
     $message->from('[email protected]', 'my site');
     $message->subject('just a test');
     $message->to('[email protected]');
});
Mail::laterOn('artwork-enquiry', 5, 'ya.profile:mail.artwork_enquiry', $data,  function ($message) use($user) {
     $message->from('[email protected]', 'my site');
     $message->subject('just a test');
     $message->to('[email protected]');
});
October build

424

Review Needed Unconfirmed Bug

All 13 comments

Can you look at the recent commits to reapply the fixes from queue and later to the queueOn and laterOn methods?

Sure can - I tried to look for the fixes in the latest commits but not seeing anything. Would I be better to enable edge updates and pull from dev branch or would this be manual fixes?

Hopefully fixed by https://github.com/octobercms/library/commit/a9c5c87603c8a3bea1fdc42b3a7ef2a4975363cd

Please test it and let us know how you went

I'm getting these errors.

For Mail::laterOn

"Type error: Argument 2 passed to Illuminate\Mail\Mailable::later() must implement interface Illuminate\Contracts\Queue\Factory, string given, called in /home/vagrant/website/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php on line 400" on line 156 of /home/vagrant/website/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php

For Mail::queueOn

"Type error: Argument 1 passed to Illuminate\Mail\Mailable::queue() must implement interface Illuminate\Contracts\Queue\Factory, string given, called in /home/vagrant/website/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php on line 357" on line 134 of /home/vagrant/website/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php

@AugmentBLU feel free to dig into this yourself to find the issue.

@AugmentBLU is this still an issue?

@AugmentBLU Please could you tell us if this is working for you ?

Please i'd appreciate some guidance as I am having the same problem using Mail::queueOn()
I reinstalled October ( build 433 ) and I doesnt seem to solve it as it was mentioned by @daftspunk.

Could someone please try this ( I'm using Redis ) :

use Mail;

Mail::queueOn( 'mail-queue' , 'plugin.mail.view' , $data, function ($message) use ($email, $name) {
    $message->to($email, $name);
});

Error :
Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Illuminate\Mail\Mailable::queue() must implement interface Illuminate\Contracts\Queue\Factory, string given, called in D:\xampp\htdocs\salons\pos5\vendor\laravel\framework\src\Illuminate\Mail\Mailer.php on line 357 in D:\xampp\htdocs\salons\pos5\vendor\laravel\framework\src\Illuminate\Mail\Mailable.php:134

error-log.txt

Composer.json

{
    "name": "october/october",
    "description": "October CMS",
    "homepage": "http://octobercms.com",
    "keywords": ["october", "cms", "octobercms", "laravel"],
    "license": "MIT",
    "authors": [
        {
            "name": "Alexey Bobkov",
            "email": "[email protected]",
            "role": "Co-founder"
        },
        {
            "name": "Samuel Georges",
            "email": "[email protected]",
            "role": "Co-founder"
        }
    ],
    "support": {
        "issues": "https://github.com/octobercms/october/issues",
        "forum": "http://octobercms.com/forum/",
        "docs": "http://octobercms.com/docs/",
        "irc": "irc://irc.freenode.net/october",
        "source": "https://github.com/octobercms/october"
    },
    "require": {
        "php": ">=7.0",
        "ext-mbstring": "*",
        "ext-openssl": "*",
        "october/rain": "~1.0",
        "october/system": "~1.0",
        "october/backend": "~1.0",
        "october/cms": "~1.0",
        "laravel/framework": "5.5.*",
        "wikimedia/composer-merge-plugin": "dev-master"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.7",
        "phpunit/phpunit": "~5.7",
        "phpunit/phpunit-selenium": "~1.2"
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php",
            "tests/UiTestCase.php",
            "tests/PluginTestCase.php"
        ]
    },
    "scripts": {
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-update-cmd": [
            "php artisan october:util set build"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "merge-plugin": {
            "include": [
                "plugins/*/*/composer.json"
            ],
            "recurse": true,
            "replace": false,
            "merge-dev": false
        }
    }
}

@rajakhoury do you have the contents of https://github.com/octobercms/library/commit/a9c5c87603c8a3bea1fdc42b3a7ef2a4975363cd in your vendor folder?

@LukeTowers Yes, I checked it yesterday after you mentioned it on Slack and again after updating.

Are you sure this is not an issue with Laravel Files ?

Looking at October\Rain\Mail\Mailer which extends Illuminate\Mail\Mailer and I see a same warning in the queue method :

Illuminate\Mail\Mailer.php
editor-warining

October.Rain.Mail.zip

@rajakhoury are you able to do some extra debugging to see if you can find the root cause and provide a fix in the form of a PR?

@LukeTowers sure i'm trying :)

@LukeTowers no luck so far - My temporary workaround is to create Jobs, dispatch it to the Mail queue , and just use the default Mail::send() - I'll keep you guys posted.

Was this page helpful?
0 / 5 - 0 ratings