承接 samcbdev/mail-notifier 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samcbdev/mail-notifier

Composer 安装命令:

composer require samcbdev/mail-notifier

包简介

Mail template generation based on user's design with custom dynamic variables

README 文档

README

The Well Organised mail Notification Manager, Ever

A custom Laravel package for dynamic mail template creation and storage in a database, with the capability to send emails using Laravel Jobs.

Features

  • Dynamic Mail Templates: Create, store, and manage dynamic mail templates in the database.
  • Filtering: Easily retrieve templates with custom filter conditions.
  • Dynamic Content Replacement: Replace dynamic fields within templates.
  • Email Sending: Send emails with support for CC, BCC, and attachments.
  • Error Handling: Handles exceptions for cases where mail templates are not found.

Tech Stack

  • Laravel: A PHP framework for building modern web applications.
  • Composer: Dependency manager for PHP.
  • MySQL: Relational database management system for storing mail templates.

Installation

  1. Composer Install Run the following command to install the package via Composer:
    composer require samcbdev/mail-notifier
  2. Vendor Publish Publish the package's configuration and other necessary files:
    php artisan vendor:publish --tag="mail-notifier"
  3. Migration Run Run the database migrations to create the necessary tables:
    php artisan migrate

Usage Guide

  1. Retrieve All Retrieve all mail templates with optional filtering:

    Mailer::filterCondition()->get();
    
    // With filters
    $filter = [
        'custom_fields->comp_id' => 1,
    ];
    Mailer::filterCondition($filter)->get();
  2. Retrieve One Retrieve a single mail template with filtering:

    $filter = [
        'custom_fields->comp_id' => 1,
    ];
    Mailer::filterCondition($filter, true)->get(); // true returns first matching record
  3. Store Store a new mail template:

    $data = [
        'template_unique_id' => 'FP',
        'custom_fields' => [ // here custom field is json column
            'comp_id' => 1
        ],
        'title' => 'Title',
        'subject' => 'Subject',
        'content' => 'Content',
        'status' => 1
    ];
    
    $setUnique = ['template_unique_id', 'custom_fields->comp_id'];
    
    Mailer::storeData($setUnique, $data);
  4. Edit Edit an existing mail template:

    $data = [
        'template_unique_id' => 'FP',
        'custom_fields' => [
            'comp_id' => 1
        ],
        'title' => 'Title',
        'subject' => 'Subject',
        'content' => 'Content',
        'status' => 2
    ];
    
    $setUnique = ['template_unique_id', 'custom_fields->comp_id'];
    
    Mailer::editData(1, $setUnique, $data);
  5. Delete Delete a mail template:

    Mailer::deleteData(1);
  6. Check Dynamic Strings Check for dynamic strings within a mail template:

    $filter = [
        'template_unique_id' => 'FP',
        'custom_fields->comp_id' => 1,
    ];
    Mailer::filterCondition($filter, true)->checkDynamicFields();
  7. Replace Dynamic Strings and Send Mail Replace dynamic fields within a mail template and send an email: setFromAddress is opitonal functional. If needs to change the from email address and mail, add the function before senMail function.

    $filter = [
        'template_unique_id' => 'FP',
        'custom_fields->comp_id' => 1,
    ];
    
    $contentArray = [
        '[[content_key]]' => 'replacing string against the key',
    ];
    
    $subjectArray = [
        '[[subject_key]]' => 'replacing string against the key'
    ];
    
    $fromAddr = [
        'name' => 'testing',
        'email' => 'from@web.php'
    ];
    
    $to = ['recipient@example.com'];
    
    $ccOrBcc = [
        'cc' => ['cc1@example.com', 'cc2@example.com'],
        'bcc' => ['bcc1@example.com']
    ];
    
    $attachments = [
        storage_path('/app/public/img.jpg'),
        storage_path('/app/public/pdf.pdf')
    ];
    
    try {
        $ret = Mailer::filterCondition($filter, true)
            ->replaceDynamicFields($contentArray, $subjectArray)
            ->setFromAddress($fromAddr)
            ->sendMail($to, $ccOrBcc, $attachments);
    } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
        return response()->json([
            'error' => 'Mail Not Send',
            'message' => $e->getMessage()
        ], 404);
    }

Development

Open your favorite Terminal and run this command.

php artisan queue:work

License

MIT

samcbdev/mail-notifier 适用场景与选型建议

samcbdev/mail-notifier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mail notifier」 「email notifications」 「dynamic email templates」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 samcbdev/mail-notifier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 samcbdev/mail-notifier 我们能提供哪些服务?
定制开发 / 二次开发

基于 samcbdev/mail-notifier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 65
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-11