iceithq/mail-php 问题修复 & 功能扩展

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

邮箱: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
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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