【问题标题】:How to use multiple API KEYs using Laravel and mandrill如何使用 Laravel 和 mandrill 使用多个 API KEY
【发布时间】:2014-11-25 15:42:37
【问题描述】:

我需要能够使用Laravel 4.2Mandrill 使用两个不同的API KEYs 发送电子邮件。

我遵循了以下教程,它与 SIGNLE API KEY(您在 services.php 中设置的那个)http://laravel.com/docs/4.2/mail 配合使用效果很好

我尝试使用以下代码即时设置不同的 API KEY(而不是使用 services.php 中的那个),但没有成功

如何在每次发送电子邮件时设置新的 API KEY?

App::bind('Mandrill', function()
{
    return new Mandrill('API KEY');
});
App::bindShared('swift.transport', function()
{
    return new MandrillTransport("API KEY");
});

// Sends Collection Email with the Unique Collection Code
Mail::send('emails.collect.collect', $data, function($message)
{
    $message->from('info@domain.com', 'mr Smith');
    $message->subject('22:24 EMAIL');
    $message->to("jonathan@mail.co.uk");
});

【问题讨论】:

    标签: laravel laravel-4 mandrill


    【解决方案1】:

    您可以在运行时更改配置:

    Config::set('services.mandrill.secret', 'YOUR API KEY');
    

    【讨论】:

      猜你喜欢
      • 2020-05-13
      • 2013-10-30
      • 1970-01-01
      • 2016-04-29
      • 2014-09-13
      • 2015-10-17
      • 2016-03-14
      • 2014-08-22
      • 2019-07-06
      相关资源
      最近更新 更多