Mailgun
Mailgun copied to clipboard
ERROR when passing a variable to to()
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
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