定制 yugo/laravel-maily 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

yugo/laravel-maily

Composer 安装命令:

composer require yugo/laravel-maily

包简介

Laravel mail transport integration for Maily.id API.

README 文档

README

SMTP-free Laravel mail transport for Maily.id.

Why this package?

Maily currently provides an API-only email service without SMTP support. This package allows Laravel applications to use Maily through Laravel Mail without changing existing mail implementations.

Features

  • Native Laravel Mail integration
  • Queue compatible
  • Notification compatible
  • API-based delivery
  • SMTP-free setup
  • Retry support

Requirements

  • PHP 8.2+
  • Laravel 11 or newer

Installation

Install the package via Composer:

composer require yugo/laravel-maily

Configuration

Add the following configuration to your config/services.php file:

'maily' => [
    'key' => env('MAILY_KEY'),
    'endpoint' => env('MAILY_ENDPOINT', 'https://maily.id'),
    'timeout' => (int) env('MAILY_TIMEOUT', 15),
    'retry' => (int) env('MAILY_RETRY', 3),
    'retry_delay' => (int) env('MAILY_RETRY_DURATION', 1_000),
],

Then add your Maily credentials to .env:

MAIL_MAILER=maily

MAILY_KEY=ml_live_your_api_key_here

# optional
MAILY_ENDPOINT=https://maily.id
MAILY_TIMEOUT=15
MAILY_RETRY=3
MAILY_RETRY_DURATION=1000

Usage

Once configured, Laravel Mail will automatically use the Maily transport.

Raw Email

use Illuminate\Support\Facades\Mail;

Mail::raw('Hello from Maily!', function ($message) {
    $message
        ->to('user@example.com')
        ->subject('Test Email');
});

Mailables

Mail::to($user)->send(new WelcomeMail());

Queued Mail

Mail::to($user)->queue(new WelcomeMail());

Events

The package dispatches a MailySentEvent event after a successful email request.

This can be useful for:

  • logging
  • analytics
  • quota monitoring
  • debugging
  • admin dashboards

Listening to the Event

<?php

namespace App\Listeners;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;
use Yugo\Maily\Events\MailySentEvent;

class GetMailyResponse
{
    /**
     * Create the event listener.
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     */
    public function handle(MailySentEvent $event): void
    {
        Log::debug('Maily response', [
            'id' => $event->id,
            'status' => $event->status,
            'message' => $event->message,
            'data' => $event->data,
        ]);
    }
}

Available Properties

$event->id;
$event->status;
$event->message;
$event->data;

The data property contains the full raw response returned by the Maily API.

Limitations

Currently, the following features are not supported due to limitations in the Maily API:

  • Attachments
  • Multiple recipients
  • CC and BCC recipients

Testing

Run the test suite using:

composer test

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固