bnomei/kirby-resend

使用 Resend 发送事务性电子邮件

安装: 0

依赖项: 0

建议者: 0

安全: 0

星级: 6

关注者: 2

分支: 0

开放性问题: 0

类型:kirby-plugin

1.0.0 2023-10-03 09:29 UTC

This package is auto-updated.

Last update: 2024-09-04 01:19:59 UTC


README

Release Downloads Build Status Coverage Status Maintainability Twitter

使用 Resend 发送事务性电子邮件

商业使用


支持开源!

此插件免费,但如果您将其用于商业项目,请考虑赞助我或捐款。
如果我的工作帮助您赚了钱,我认为我也应该得到一点回报,对吧?

友善。分享一点。谢谢。

- Bruno
 

通过 SMTP 发送

<?php

// regular "transactional" email
$to = 'roger.rabbit@disney.com';

$success = kirby()->email([
    'from' => new \Kirby\Cms\User([
        'email' => 'resend@example.com', // your verified resend sender
        'name' => 'Example Name', // your name
    ]),
    'to' => $to,
    'subject' => 'Sending E-Mails is fun',
    'body' => [
        'html' => '<h1>Headline</h1><p>Text</p>',
        'text' => "Headline\n\nText",
    ],
    'transport' => resend()->transport(), // plugin helper to get SMTP config array
])->isSent();

通过 PHP 库发送(正在进行中)

$client = resend()->client();
$sendResult = $client->emails->send([
    'from' => 'onboarding@resend.dev',
    'to' => 'delivered@resend.dev',
    'subject' => 'Hello World',
    'html' => '<strong>it works!</strong>',
]);

// Getting the ID from the response Email object
// https://github.com/resendlabs/resend-php/blob/main/src/Email.php
echo $sendResult->id;

通过 Resend 发送 Kirby Panel 邮件

如果您想使 Kirby 使用 Resend 发送电子邮件(如面板中的密码重置),您必须设置全局 authemail 配置值。

site/config/config.php

return [
    // …other settings
    'auth' => [
        'methods' => ['password', 'password-reset'],
        'challenge' => [
            'email' => [
                'from'     => 'resend@example.com', // your verified postmark sender
                'fromName' => 'Example Name',
            ]
        ]
    ],
    'email' => [
        'transport' => [
            'type' => 'smtp',
            'host' => 'smtp.resend.com',
            'port' => 587,
            'security' => true,
            'auth' => true,
            'username' => 'resend', // needs to be 'resend'
            'password' => 'YOUR-APIKEY-HERE', // your resend apikey
        ]
    ]
];

设置

您可以在配置中设置 API 密钥。

site/config/config.php

return [
    // other config settings ...
    'bnomei.resend.apikey' => 'YOUR-APIKEY-HERE',
];

如果您使用 dotenv 插件,您还可以设置回调。

site/config/config.php

return [
    // other config settings ...
    'bnomei.resend.apikey' => function() { return env('RESEND_APIKEY_TOKEN'); },
];

设置

依赖项

免责声明

此插件“原样提供”,不提供任何保证。请自行承担使用风险,并在将其用于生产环境之前自行测试。如果您发现任何问题,请 创建新问题

许可证

MIT

不建议在任何宣传种族主义、性别歧视、恐同、动物虐待、暴力或其他任何形式仇恨言论的项目中使用此插件。