Comments (11)
I was thinking maybe something like
foreach ($emails as $email) {
Mailgun::send('emails.notice', $data, function($message) use ($email, $subject){
$message->to($email)->subject($subject);;
});
}
I haven't really looked at how the library works yet though so didn't know if that would work
from mailgun.
@evandentremont Have you tried it this?
Mailgun::send('emails.welcome', $data, function($message)
{
$message->to(array(
'[email protected]',
'[email protected]'
));
});
from mailgun.
Thanks for the quick reply!
I haven't, I'm doing this right now
https://github.com/evandentremont/DanceDB/blob/master/app/controllers/ContactController.php#L45
I'll give that a shot.
from mailgun.
Nevermind, just tried it. That method does the same thing.
from mailgun.
@evandentremont You probably shouldn't do that unless you are only sending it to 2 or 3 addresses.
Give me a minute to figure out the issue.
from mailgun.
Yeah it's about 80, wanted to avoid it. Thanks for looking into it
from mailgun.
@evandentremont To achieve this you need to make use of recipient variables.
A quick example:
Mailgun::send('emails.notice', $data, function($message)
{
$message->to([
'[email protected]',
'[email protected]',
'[email protected]',
]);
$message->recipientVariables([
'[email protected]' => ['name' => 'John Doe'],
'[email protected]' => ['name' => 'Foo Bar'],
'[email protected]' => ['name' => 'Baz Bar'],
]);
});
With the above you specify the data that belongs to the address.
Now when using the name
variable in your template it will be mapped to the correct user.
If you don't have any user specific data you can pass an empty array:
Mailgun::send('emails.notice', $data, function($message)
{
$message->to([
'[email protected]',
'[email protected]',
'[email protected]',
]);
$message->recipientVariables([
'[email protected]' => [],
'[email protected]' => [],
'[email protected]' => [],
]);
});
Please let me know if this works out for you.
from mailgun.
Yes, that worked!
Kept the foreach and added recipientVariables to it.
from mailgun.
Another option would be to use Mailgun's mailinglists.
I'm currently working on implementing mailinglists into this package.
Though a quick peek at your code tells me mailinglists is probably not the correct solution in your case.
From the Mailgun Documentation:
Batch Sending
Mailgun supports the ability send to a group of recipients through a single API call.
This is achieved by either:
- Using Batch Sending by specifying multiple recipient email addresses as to parameters and using Recipient Variables.
- Using Mailing Lists with Template Variables.
Warning It is important when using Batch Sending to also use Recipient Variables. This tells Mailgun to send each recipient an individual email with only their email in the to field. If they are not used, all recipients’ email addresses will show up in the to field for each recipient.
from mailgun.
Not really, no. I'm sending to every user whos in a class on a specific day, and in a specific class soon.
Would need thirty-something mailing lists.
Thanks for the help!
from mailgun.
No problem, glad I could help.
I believe you can create a maximum of a 1000 mailinglists with a maximum of 2.500.000 members.
from mailgun.
Related Issues (20)
- Clarification please regarding handling of http_response_body content and possibly guzzle and/or env setting? HOT 3
- Undefined Method error
- Type error: Argument 1 passed must be an instance of App\Http\Controllers\Message HOT 1
- Example send email to mailing list HOT 1
- Troubles with the API request, deprecated usable of mailgun-php lib HOT 2
- .
- Trying to get property of non-object HOT 1
- Update nesbot/carbon dependency HOT 1
- Cannot install php-http/guzzle6-adapter HOT 2
- Switching endpoint HOT 2
- Using full api from mailgun-php HOT 2
- Install on Laravel 5.8? HOT 4
- ERROR when passing a variable to to() HOT 1
- new release 5.1.0 with Carbon 2 is not available via composer and isn't on packagist HOT 1
- Error installing this package on Laravel 5.8 (clunky workaround included...can we fix the package?) HOT 1
- Upgrade Laravel 6 HOT 1
- Unable to install php-http / guzzle6-adapter in symfony 4.1
- Emails are not being sent or received.
- Mailgun custom notification channel
- specific attachment to each recipient in batch emails
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mailgun.