定制 iceithq/mail-php 二次开发

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

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

iceithq/mail-php

最新稳定版本:v0.0.3

Composer 安装命令:

composer require iceithq/mail-php

包简介

README 文档

README

A simple PHP class for sending emails (with optional attachments) through an API endpoint.
Designed under the namespace com\iceithq.

Installation

  1. Make sure you have Composer installed.
  2. In your project, add this package to your composer.json autoload section:
"autoload": {
  "psr-4": {
    "com\\iceithq\\": "src/"
  }
}
  1. Run:
composer dump-autoload
  1. Require Composer’s autoloader in your project:
require __DIR__ . '/vendor/autoload.php';

Usage

Basic Example

<?php

use com\iceithq\Mail;

$mail = new Mail("https://api.example.com");

$response = $mail->to("recipient@example.com")
                 ->attach("/path/to/file1.pdf")
                 ->attach(["/path/to/file2.jpg", "/path/to/file3.png"]) // multiple attachments
                 ->send("Test Subject", "This is the body of the message.");

echo $response;

API

__construct($api_url = '')

Create a new mail instance.

to($to)

Set the recipient email address.

  • $to – Recipient’s email (string).

attach($filePath)

Attach a file or multiple files to the email.

  • $filePath – Either a string (single file path) or an array of file paths.

send($subject, $body)

Send the email request to the configured API.

  • $subject – Email subject (string).
  • $body – Email body (string).
  • Returns – The raw API response.

Notes

  • By default, Authorization: Bearer is included in the request header.
  • Replace $apiKey inside the class with your real API key or extend the class to pass it dynamically.
  • Payload is sent as multipart/form-data so file uploads work correctly.
  • Error handling is minimal right now. You may want to expand it for production use.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-18