Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Add custom email subject support to scheduled tasks #16598

Conversation

stevenmaguire
Copy link
Contributor

These changes add an optional emailSubject attribute to the Illuminate\Console\Scheduling\Event which, when set, will become the subject for the notification email that is sent. If this option is not configured, the existing default behavior will resume.

$schedule->command('foo')
         ->daily()
         ->sendOutputTo($filePath)
         ->emailSubject('My awesome custom subject')
         ->emailOutputTo('foo@example.com');

This PR also includes an additional unit test to verify these changes. Due to the use of the global file_get_contents function and some of the gnarly bits inside the mailing infrastructure, this test case is not as elegant as I would like. It does however exercise the functionality and test the actual email message attributes rather than mock intermediate methods.

@stevenmaguire stevenmaguire force-pushed the add-custom-email-subject-to-scheduled-task branch from 84818cf to d368b3f Compare November 30, 2016 06:11
@stevenmaguire stevenmaguire force-pushed the add-custom-email-subject-to-scheduled-task branch from d368b3f to d599861 Compare November 30, 2016 06:12
@GrahamCampbell GrahamCampbell changed the title Add custom email subject support to scheduled tasks [5.3] Add custom email subject support to scheduled tasks Nov 30, 2016
@taylorotwell
Copy link
Member

You can already customize the subject by setting a description.

@stevenmaguire
Copy link
Contributor Author

stevenmaguire commented Dec 4, 2016

@taylorotwell While it is true that by setting a description it alters the email subject, the framework still forces the subject to include "Scheduled Job Output"; which is a reasonable default if email subject is not explicitly defined.

https://github.com/laravel/framework/blob/5.3/src/Illuminate/Console/Scheduling/Event.php#L844

    /**
     * Get the e-mail subject line for output results.
     *
     * @return string
     */
    protected function getEmailSubject()
    {
        if ($this->description) {
            return 'Scheduled Job Output ('.$this->description.')';
        }
        return 'Scheduled Job Output';
    }

If a consumer of this framework wants to customize this subject line, especially to not include "Scheduled Job Output" (an english-only opinion), why not enable that? What is the basis for the objection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants