Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
iwasherefirst2 authored Sep 20, 2019
1 parent 7984473 commit f574eaa
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ The `from` method from `MultiMail` needs a string of an email provided in `confi

This example assumes that `[email protected]` and `[email protected]` have been specified in `config/multimail.php`.

// Send Mail - send mail from [email protected], receiver should be specified in mailable
\MultiMail::from('[email protected]')->send(new \App\Mail\Invitation($user, $form));
// Send mail from [email protected]
\MultiMail::to($user)->from('[email protected]')->send(new \App\Mail\Invitation($user));

// Send Mail with optional parameters 'to' and 'locale' from malaccount [email protected]
\MultiMail::to('[email protected]')->from('[email protected]')->locale('en')->send(new \App\Mail\Invitation($user));
// Send from malaccount [email protected]
\MultiMail::to($user)->from('[email protected]')->locale('en')->send(new \App\Mail\Invitation($user));

### Queued Mails

Expand Down Expand Up @@ -144,6 +144,38 @@ You may provide `default` credentials inside the `email` array from `config/mult

When `first_mail_password` and `first_mail_username` are empty, `[email protected]` will use credentials specified by `default`. This is useful for your local development, when you want to send all mains from one mailaccount while testing.

#### Specify everything in mailable

You may set `to`, `cc`, `bcc`, `locale` and `from` in your mailable class. In this case, you could reduce the basic example from above to:

// Send mail from [email protected]
\MultiMail::send(new \App\Mail\Invitation($user));

Mailable:

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($user)
{
$this->to = $user;
$this->fromMailer = '[email protected]'
$this->locale('en');
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.invitation')
->subject('Invitation mail')
}

### Advice

#### Production environment
Expand All @@ -156,3 +188,4 @@ Do not specify any email acounts in your local `.env`. Otherwise you may risk to
Instead use `log` driver or setup a fake mail SMTP account like [mailtrap](https://mailtrap.io/) or similar services.

If you want to use a fake mail SMPT account for testing, it is not needed to specifiy the same credentials for any email account. Instead, simply provide a default mail account (see above `Default mailaccount`).

0 comments on commit f574eaa

Please sign in to comment.