{"id":19300049,"url":"https://github.com/kirschbaum-development/nova-mail","last_synced_at":"2025-04-09T16:10:43.012Z","repository":{"id":37470881,"uuid":"185282007","full_name":"kirschbaum-development/nova-mail","owner":"kirschbaum-development","description":"A Laravel Nova action that provides a mail sending form for any resource","archived":false,"fork":false,"pushed_at":"2022-06-21T14:31:41.000Z","size":2152,"stargazers_count":74,"open_issues_count":7,"forks_count":25,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-09T16:10:38.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kirschbaum-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-06T22:43:50.000Z","updated_at":"2025-04-05T20:50:24.000Z","dependencies_parsed_at":"2022-09-05T21:10:53.728Z","dependency_job_id":null,"html_url":"https://github.com/kirschbaum-development/nova-mail","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fnova-mail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fnova-mail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fnova-mail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirschbaum-development%2Fnova-mail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirschbaum-development","download_url":"https://codeload.github.com/kirschbaum-development/nova-mail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065284,"owners_count":21041872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:13:31.891Z","updated_at":"2025-04-09T16:10:42.992Z","avatar_url":"https://github.com/kirschbaum-development.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![banner](screenshots/banner.png)\n# Nova Mail\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/kirschbaum-development/nova-mail.svg?style=flat-square)](https://packagist.org/packages/kirschbaum-development/nova-mail)\n[![Total Downloads](https://img.shields.io/packagist/dt/kirschbaum-development/nova-mail.svg?style=flat-square)](https://packagist.org/packages/kirschbaum-development/nova-mail)\n\nThis package contains a Nova action that provides a mail sending form for any resource to easily send email. It also includes automated mail sending based on Eloquent Model events/attribute changes.\n\n![screenshot of the send mail action modal](screenshots/send-mail-modal-empty.png)\n\n![screenshot of the send mail action modal with template selected](screenshots/send-mail-modal-template-selected.png)\n\n![screenshot of mail template model events](screenshots/mail-template-model-events.png)\n\n## Requirements\n\nThis Nova package requires Nova 4.0 or higher. If you are using a Nova version \u003c 4.0, then you'll want to use [v1.0.4](https://github.com/kirschbaum-development/nova-mail/tree/1.0.4) (no longer updated).\n\nUsing the mail delay feature requires a queue driver other than sync. If you are using the Amazon SQS queue service, the maximum delay time is 15 minutes.\n\n## Installation\n\nYou can install this package in a Laravel app that uses [Nova](https://nova.laravel.com) via composer:\n\n```bash\ncomposer require kirschbaum-development/nova-mail\n```\n\nNext, we need to run migrations. Auto-discovery of this package's service provider helps with that!\n\n```bash\nphp artisan migrate\n```\n\nAnd lastly, any model that you want to send mail needs the `Mailable` trait added to it. The model should have a compliant email column. You also need to implement the abstract method provided by the `Mailable` trait, like shown below. You should customize this if your email column name is different:\n\n```php\nuse KirschbaumDevelopment\\NovaMail\\Traits\\Mailable;\n\nclass User extends Model\n{\n    use Mailable;\n\n    /**\n     * Get the name of the email field for the model.\n     *\n     * @return string\n     */\n    public function getEmailField(): string\n    {\n        return 'email';\n    }\n\n    // ...\n}\n```\n\nIf you would like to publish the config for this package, run:\n\n```bash\nphp artisan vendor:publish\n```\nAnd choose the provider for this package: `KirschbaumDevelopment\\NovaMail\\NovaMailServiceProvider`\n\n## Usage\n\nThere is a single action (`SendMail`) and two resources (`NovaMailTemplate` and `NovaSentMail`) that ship with this package. Internally the `SendMail` action uses a custom Nova field to display the inline mail sending form.\n\n### SendMail action\n\nThe `SendMail` action inserts a mail form directly into a Nova action modal. This action allows you to quickly send an email directly to one or more resources.\n\nSimply add the `KirschbaumDevelopment\\NovaMail\\Actions\\SendMail` action to your Nova resource:\n\n```php\nnamespace App\\Nova;\n\nuse KirschbaumDevelopment\\NovaMail\\Actions\\SendMail;\n\nclass User extends Resource\n{\n    // ...\n\n    public function actions(Request $request)\n    {\n        return [\n            // ...\n\n            new SendMail,\n        ];\n    }\n}\n```\n\nNow you can send emails from the action called \"Send Mail\" on your resource!\n\nYou can also delay any outgoing email by setting the delay in minutes property on the template. Like subject and body, you can override the mail delay specified in the template when you send mail.\n\n### Trigger Mail on Model Events\n\nA `MailTemplate` can be configured to respond to Eloquent Model events, or a value change of a specified column. For example, a mail template informing your users of their account status could be sent when the `active` column on your `User` model is updated:\n\n![screenshot of the account status mail template](screenshots/model-event-account-status-change.png)\n\nYou can even have separate Model Events for both \"on\" an \"off\"!\n\n![screenshot of the account status with value mail template](screenshots/model-event-account-status-change-with-value.png)\n\n### Mail Template Usage/Caveats\n\nThe `NovaMailTemplate` resource allows you to create re-usable custom templates for sending email. It works by taking your specified template (or over-ridden template content) and building a temporary blade file (the Blade file can be saved permantely via a configuration option). This blade file is then used in the typical Laravel fashion to send the email.\n\nThe final content provided when the user clicks the \"Send Mail\" button is parsed as markdown and makes no assumptions about newlines or any other formatting for that matter. For example, if you were to use the built in mail message component provided by Laravel for markdown emails you could create a template like the following:\n\n```\n@component('mail::message')\nHello {{ $name }},\n\nVisit this link when you have a moment:\n\n[https://github.com/kirschbaum-development/nova-mail](https://github.com/kirschbaum-development/nova-mail)\n\nLet me know if you have any questions.\n\n@include('path.to.footer')\n@endcomponent\n```\n\n![screenshot of the create mail template](screenshots/create-mail-template.png)\n\n### Sent Mail Usage\n\nThe `NovaSentMail` resource can be added as a relationship field to any `Resource` that has the `Mailable` trait defined on it's corresponding model. This gives you direct access to the history of emails sent from that `Resource`:\n\n```php\nnamespace App\\Nova;\n\nuse Laravel\\Nova\\Fields\\HasMany;\nuse KirschbaumDevelopment\\NovaMail\\Nova\\NovaSentMail;\n\nclass User extends Resource\n{\n    // ...\n\n    public function fields(Request $request)\n    {\n        return [\n            // ...\n\n            HasMany::make('Sent Mail', 'mails', NovaSentMail::class),\n\n            // ...\n        ];\n    }\n}\n```\n\n![screenshot of the sent mail index](screenshots/nova-sent-mail.png)\n\n## Resource Customization\n\nIn case you need to customize the `Nova Resources` that you're using in your application, for instance, to add filters, cards or add fields. You can change the default set of classes.\nFirst, you'll need to override the array of `Resources` found in the config file (If you haven't published a config file yet please see the **Installation** section):\n\n```php\n    /*\n    |--------------------------------------------------------------------------\n    | Default Resources\n    |--------------------------------------------------------------------------\n    |\n    | This determines which Nova Resources you're using\n    | You can change it as you wish\n    |\n    */\n    'default_resources' =\u003e [\n        'nova_mail_event' =\u003e App\\Nova\\YourNovaMailEventResource::class,\n        'nova_mail_template' =\u003e App\\Nova\\YourNovaMailTemplateResource::class,\n        'nova_sent_mail' =\u003e App\\Nova\\YourNovaSentMailResource::class,\n    ],\n```\n\nAfter that you can `extends` the default `Resource Class` and add your custom code like this:\n\n```php\nuse KirschbaumDevelopment\\NovaMail\\Nova\\NovaSentMail;\n\nclass YourNovaSentMailResource extends NovaSentMail\n{\n    public function cards(Request $request)\n    {\n        return [\n            // Your custom code...\n        ];\n    }\n}\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email adam@kirschbaumdevelopment.com or nathan@kirschbaumdevelopment.com instead of using the issue tracker.\n\n## Credits\n\n- [Adam Parker](https://github.com/adammparker)\n- [Brandon Ferens](https://github.com/brandonferens)\n- [Justin Seliga](https://github.com/jrseliga)\n- [Belisar Hoxholli](https://github.com/belisarh)\n\n## Sponsorship\n\nDevelopment of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more [about us](https://kirschbaumdevelopment.com) or [join us](https://careers.kirschbaumdevelopment.com)!\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirschbaum-development%2Fnova-mail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirschbaum-development%2Fnova-mail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirschbaum-development%2Fnova-mail/lists"}