Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

ERROR when passing a variable to to() #154

Open
D-sense opened this issue Jun 11, 2019 · 1 comment
Open

ERROR when passing a variable to to() #154

D-sense opened this issue Jun 11, 2019 · 1 comment

Comments

@D-sense
Copy link

D-sense commented Jun 11, 2019

Hi,

I get an error each time I try passing a variable to the to().
Example:
->to($user_email_address, 'John Doe')

In addition, is it possible to use this with Mailable? Like passing mailable as opposed to passing email path?

Is there any way around this?
Thanks

@cosmini
Copy link

cosmini commented Sep 2, 2019

You'll have to use inheritance see anonymous functions here https://www.php.net/manual/en/functions.anonymous.php

Step 3 is what you're after

$user_email_address = '[email protected]';
Mailgun::send('foo.bar', ['foo' => 'bar], function ($message) use ($user_email_address) {
  $message->to($user_email_address, 'John Doe');
});

Note the keyword use

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

No branches or pull requests

2 participants