Code Monkey home page Code Monkey logo

Comments (11)

 avatar commented on May 30, 2024 1

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.

Bogardo avatar Bogardo commented on May 30, 2024

@evandentremont Have you tried it this?

Mailgun::send('emails.welcome', $data, function($message)
{
    $message->to(array(
        '[email protected]',
        '[email protected]'
    ));
});

from mailgun.

 avatar commented on May 30, 2024

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.

Bogardo avatar Bogardo commented on May 30, 2024

Nevermind, just tried it. That method does the same thing.

from mailgun.

Bogardo avatar Bogardo commented on May 30, 2024

@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.

 avatar commented on May 30, 2024

Yeah it's about 80, wanted to avoid it. Thanks for looking into it

from mailgun.

Bogardo avatar Bogardo commented on May 30, 2024

@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.

 avatar commented on May 30, 2024

Yes, that worked!

Kept the foreach and added recipientVariables to it.

from mailgun.

Bogardo avatar Bogardo commented on May 30, 2024

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.

 avatar commented on May 30, 2024

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.

Bogardo avatar Bogardo commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.