cyberwizard/sendgrid-mailer
Composer 安装命令:
composer require cyberwizard/sendgrid-mailer
包简介
A Laravel package for sending 'templated based' emails using SendGrid API KEY
README 文档
README
Cyberwizard SendGrid Mailer is a Laravel package designed to simplify the process of sending emails using SendGrid API KEY and Laravel Blade templates. This package is useful when you need to send emails with dynamic content generated from Blade templates while leveraging the power of SendGrid for email delivery.
Why Cyberwizard SendGrid Mailer?
When integrating SendGrid with Laravel applications, you might want to utilize Blade templates for email content generation. However, using Blade templates directly with SendGrid API can be challenging due to compatibility issues. Cyberwizard SendGrid Mailer solves this problem by providing a seamless integration between Laravel Blade templates and SendGrid API.
Installation
You can install the package via Composer:
composer require cyberwizard/sendgrid-mailer:dev-main
Usage
Once installed, you can use the sendEmail method provided by the Cyberwizard\SendGridMailer\CyberSendGridMailer
class to send emails. Here's how you can use it:
use Cyberwizard\SendGridMailer\CyberSendGridMailer; $subject = 'Your email subject'; $to = 'recipient@example.com'; $fromEmail = 'sender@example.com'; $fromName = 'Sender Name'; $templatePath = 'emails.template'; // Path to your Blade template $data = [ 'name' => 'John Doe', 'order_id' => '123456', // Add more key-value pairs as needed ]; try { $success = CyberSendGridMailer::sendEmail($subject, $to, $fromEmail, $fromName, $templatePath, $data); if ($success) { // Email sent successfully } else { // Email sending failed } } catch (\Exception $e) { // Handle exception }
Environment Configuration
Before using the package, make sure to set your SendGrid API key in your .env file:
SENDGRID_API_KEY=your-sendgrid-api-key
Parameters
$subject(string): The subject of the email.$to(string): The recipient email address.$fromEmail(string): The sender's email address.$fromName(string, optional): The sender's name.$templatePath(string): The path to the email template in your views directory. For example:'emails.template'.$data(array, optional): The data to pass to the email template. For example:[ 'name' => 'John Doe', 'order_id' => '123456', // Add more key-value pairs as needed ]
License
This package is open-source software licensed under the MIT license.
cyberwizard/sendgrid-mailer 适用场景与选型建议
cyberwizard/sendgrid-mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 392 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cyberwizard/sendgrid-mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cyberwizard/sendgrid-mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 392
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-02-07