descubraomundo/notifymehq-mail 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

descubraomundo/notifymehq-mail

Composer 安装命令:

composer require descubraomundo/notifymehq-mail

包简介

Provides a mail gateway for notifyme

README 文档

README

Build Status

NotifyMeHQ Mail

An UNOFFICIAL Mail gateway for NotifyMeHQ as they "intentionally removed mail support" for NotifyMeHQ.

If you want to keep the default contract of NotifyMeHQ public function notify($to, $message); with both parameters as a string, the expected behavior is:

  1. The recipient of the email notificafion will not have his name on the recipients information, it will only be the email.
  2. The subject of the email will be the first 75 characters of the $message content, but all HTML tags will be removed.
  3. The body of the email, will be the content of the $message it self with all the HTML tags. * If the body of the email, is a HTML, it will automatically create a Plain text of it, formated just like the HTML, so it will reduce the SPAM score for that email. * If the body has no HTML, it will be sent as plain text.

Otherwise you can send the $message variable as an array with the desired configurations below.

Configuration

Here is the list of all available configurations that you can provide for you notifierFactory and for your notification.

Notifier

Configuration Required Description
host true Specify your SMTP Server Host.
port true Specify your SMTP Server Port, check with your host. Eg: 25 or 465 or 2525.
encryption true Specify your SMTP Server Encryption, check with your host. Eg: tls or ssl.
username true Specify your SMTP Server Username.
password true Specify your SMTP Server Password.
subject optional Specifies the subject line that is displayed in the recipients' mail client.
cc optional Specifies the addresses of recipients who will be copied in on the message.
bcc optional Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies.
replyTo optional Specifies the address where replies are sent to.
from optional Specifies the sender address if you want to overwrite the value set on the configuration properties.
contentType optional Specifies the format of the message (usually text/plain or text/html).
date optional Specifies the unix time stamp date at which the message was sent.
returnPath optional Specifies where bounces should go (Swift Mailer reads this for other uses).
priority optional Specifies the email priority. Setting the priority will not change the way your email is sent It is purely an indicative setting for the recipient.

Notification

If you provide any of the configuration bellow, they will overwrite the default configuration provided for the notifierFactory.

Configuration Required Description
subject true Specifies the subject line that is displayed in the recipients' mail client.
body true Specifies the body of the email that the recipient will receive.
cc optional Specifies the addresses of recipients who will be copied in on the message.
bcc optional Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies.
replyTo optional Specifies the address where replies are sent to.
from optional Specifies the sender address if you want to overwrite the value set on the configuration properties.
contentType optional Specifies the format of the message (usually text/plain or text/html).
id optional Identifies this message with a unique ID, usually containing the domain name and time generated.
date optional Specifies the unix time stamp date at which the message was sent.
returnPath optional Specifies where bounces should go (Swift Mailer reads this for other uses).
priority optional Specifies the email priority. Setting the priority will not change the way your email is sent It is purely an indicative setting for the recipient.

Advanced

body

For the body value you can provide both versions(HTML and plain text):

    'body'    => [
        'html'  => 'My <em>amazing</em> body',
        'plain' => 'My amazing body'
    ],

Or you can provide only one version, and we will detect automatically if is HTML or plain text and configure correctly:

    'body'    => 'My <em>amazing</em> body'  // It will be sent as HTML

OR

    'body'    => 'My amazing body'           // It will be sent as plain text

from, to, cc, bcc, replyTo

For all email recipients / sender configuration you can provide them in two variants:

Email and Name (As an array)

    'from|to|cc|bcc|replyTo' => ['email@example.com', 'Example Name'],

Email Only (As a string)

    'from|to|cc|bcc|replyTo' => 'email@example.com',

priority

This configuration takes an integer value between 1 and 5:

  • Highest (1)
  • High (2)
  • Normal (3)
  • Low (4)
  • Lowest (5)

Example

<?php
    // Create a factory for notifications.
    $notifierFactory = new NotifyMeHQ\NotifyMe\NotifyMeFactory();

    // Create the new notification for mail.
    $mailNotifier = $notifierFactory->make([
      // Specify that we will use mail.
      'driver' => 'mail',
      // Specify your SMTP Server Host.
      'host' => '',
      // Specify your SMTP Server Port, check with your host. Eg: 25 or 465 or 2525.
      'port' => 25,
      // Specify your SMTP Server Username.
      'username' => '',
      // Specify your SMTP Server Password.
      'password' => '',
      // Specify your Sender details. It can be a simple email, or a email with a name.
      'from' => ['from@example.com','Example Sender'], // Email & Name
    ]);

    /**
     * RECIPIENTS:
     */
    $recipient = ['recipient@example.com', 'Recipient Name'];

    /**
     * EMAIL
     */
    $email = [
        // Specifies the subject line that is displayed in the recipients' mail client
        'subject' => 'Test',
        // Specifies the body of the email that the recipient will receive.
        'body'    => [
            'html'  => 'My <em>amazing</em> body',
            'plain' => 'My amazing body'
        ],
        // Specifies the addresses of recipients who will be copied in on the message
        'cc' => ['cc@email.com', 'CC Name'],
        // Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies.
        'bcc' => ['bcc@email.com', 'BCC Name'],
        // Specifies the address where replies are sent to
        'replyTo' => ['replyto@email.com', 'Reply To Name'],
        // Specifies the sender address if you want to overwrite the value set on the configuration properties.
        'from' => ['otherFrom@email.com', 'Other Sender Name'],

        /**
         * ADVANCED OPTIONS
         */
        // Specifies the format of the message (usually text/plain or text/html)
        'contentType' => 'text/html',
        // Specifies where bounces should go (Swift Mailer reads this for other uses)
        'returnPath' => 'bounces@email.com',
        // Specifies the email priority.
        'priority' => '2', // Indicates "High" priority.
    ];

    /* @var \NotifyMeHQ\Contracts\ResponseInterface $response */
    $response =  $mailNotifier->notify($recipient, $email);

    echo $response->isSent() ? 'Message sent' : 'Message going nowhere';

Todo

  • Add tests

License

NotifyMe is licensed under The MIT License (MIT).

descubraomundo/notifymehq-mail 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-16