Skip to content

2.0.0 #1

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

Merged
merged 19 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
language: php

php:
- 5.6
- 7.0
- 7.1

sudo: false

install: travis_retry composer install --no-interaction --prefer-source

script: vendor/bin/phpunit --verbose
script: vendor/bin/phpunit --verbose
69 changes: 48 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Introduction

This is a package that stores and queues e-mails using a database table. Easily send e-mails using a cronjob or schedule e-mails that should be sent at a specific date and time.
This is a package that stores and queues e-mails using a database table. Easily send e-mails using a cronjob and schedule e-mails that should be sent at a specific date and time.
## Installation

First, require the package using composer.
Expand All @@ -24,16 +24,15 @@ If you're running Laravel 5.5 or later you may skip this step. Add the service p
Buildcode\LaravelDatabaseEmails\LaravelDatabaseEmailsServiceProvider::class,
```

Publish the configuration file.
Publish the configuration files.

```bash
$ php artisan vendor:publish --provider=Buildcode\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
```

Create the e-mails database table migration.
Create the database table required for this package.

```bash
$ php artisan email:table
$ php artisan migrate
```

Expand All @@ -57,7 +56,7 @@ protected function schedule(Schedule $schedule)
### Create An Email

```php
Buildcode\LaravelDatabaseEmails\Email::compose()
Email::compose()
->label('welcome-mail-1.0')
->recipient('john@doe.com')
->subject('This is a test')
Expand All @@ -68,20 +67,53 @@ Buildcode\LaravelDatabaseEmails\Email::compose()
->send();
```

### Specify Recipients

```php
$one = 'john@doe.com';
$multiple = ['john@doe.com', 'jane@doe.com'];

Email::compose()->recipient($one);
Email::compose()->recipient($multiple);

Email::compose()->cc($one);
Email::compose()->cc($multiple);

Email::compose()->bcc($one);
Email::compose()->bcc($multiple);
```

### Mailables

You may also pass a mailable to the e-mail composer.

```php
Email::compose()
->mailable(new OrderShipped())
->send();
```

### Attachments

```php
Email::compose()
->attach('/path/to/file');
```

Or for in-memory attachments...

```php
Email::compose()
->attachData('<p>Your order has shipped!</p>', 'order.html');
```

### Schedule An Email

You may schedule an e-mail by calling `schedule` instead of `send` at the end of the chain. You must provide a Carbon instance or a strtotime valid date.
You may schedule an e-mail by calling `later` instead of `send` at the end of the chain. You must provide a Carbon instance or a strtotime valid date.

```php
Buildcode\LaravelDatabaseEmails\Email::compose()
->label('welcome-mail-1.0')
->recipient('john@doe.com')
->subject('This is a test')
->view('emails.welcome')
->variables([
'name' => 'John Doe',
])
->schedule('+2 hours');
Email::compose()
->later('+2 hours');
```

### Manually Sending E-mails
Expand Down Expand Up @@ -112,11 +144,6 @@ If you wish to encrypt your e-mails, please enable the `encrypt` option in the c

### Testing Address

If you wish to send e-mails to a test address but don't necessarily want to use a service like mailtrap, please take a look at the `testing` configuration. This is turned on by default.
If you wish to send e-mails to a test address but don't necessarily want to use a service like mailtrap, please take a look at the `testing` configuration. This is turned off by default.

During the creation of an e-mail, the recipient will be replaced by the test e-mail. This is useful for local development or testing on a staging server.

## Todo

- Add support for attachments
- Add support for Mailables
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"email": "info@marickvantuil.nl"
}
],
"require": {
"illuminate/database": "^5.2",
"illuminate/console": "^5.2",
"illuminate/validation": "^5.2"
},
"autoload": {
"psr-4": {
"Buildcode\\LaravelDatabaseEmails\\": "src/"
Expand All @@ -31,8 +26,13 @@
}
},
"require-dev": {
"orchestra/testbench": "~3.4",
"phpunit/phpunit": "^5.7",
"orchestra/database": "~3.4"
"illuminate/database": "^5.5",
"illuminate/console": "^5.5",
"illuminate/validation": "^5.5",
"orchestra/testbench": "^3.5",
"orchestra/database": "^3.5",
"phpunit/phpunit": "^6.0",
"mockery/mockery": "^1.0",
"dompdf/dompdf": "^0.8.2"
}
}
4 changes: 3 additions & 1 deletion config/laravel-database-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
'email' => 'test@email.com',

'enabled' => function () {
return app()->environment('local', 'staging');
return false;
// ...or...
// return app()->environment('local', 'staging');
}

],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class Create{{tableClassName}}Table extends Migration
class CreateEmailsTable extends Migration
{
/**
* Run the migrations.
Expand All @@ -13,7 +13,11 @@ class Create{{tableClassName}}Table extends Migration
*/
public function up()
{
Schema::create('{{table}}', function (Blueprint $table) {
if (Schema::hasTable('emails')) {
return;
}

Schema::create('emails', function (Blueprint $table) {
$table->increments('id');
$table->string('label')->nullable();
$table->binary('recipient');
Expand Down Expand Up @@ -43,6 +47,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('{{table}}');
//
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddAttachmentsToEmailsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasColumn('emails', 'attachments')) {
return;
}

Schema::table('emails', function (Blueprint $table) {
$table->binary('attachments')->after('body')->default('');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
4 changes: 2 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Config
*
* @return int
*/
public static function maxRetryCount()
public static function maxAttemptCount()
{
return max(config('laravel-database-emails.retry.attempts', 1), 3);
}
Expand Down Expand Up @@ -59,4 +59,4 @@ public static function cronjobEmailLimit()
{
return config('laravel-database-emails.limit', 20);
}
}
}
112 changes: 0 additions & 112 deletions src/CreateEmailTableCommand.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Decorators/EmailDecorator.php

This file was deleted.

Loading