lazervel/mailsender 问题修复 & 功能扩展

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

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

lazervel/mailsender

最新稳定版本:v1.0.0

Composer 安装命令:

composer require lazervel/mailsender

包简介

Modern PHP mailer built on PHPMailer for easy integration.

README 文档

README

Lightweight PHP library for effortless email sending.
Built on top of PHPMailer, it provides an easy and elegant way to send HTML emails with inline CSS, embedded images, and attachments.

🚀 Features

  • Simple and clean wrapper for PHPMailer
  • Inline CSS support (<link rel="stylesheet"> auto inlines to <style>)
  • Embedded local images automatically converted to CID
  • File and base64 attachments support
  • Handles multiple recipients with one call
  • Easy integration with environment variables (.env or $_ENV)

📥 Installation

Install via Composer:

composer require lazervel/mailsender

Or manually add to your composer.json:

{
  "require": {
    "lazervel/mailsender": "^1.0"
  }
}

🧩 Basic Usage

<?php

require 'vendor/autoload.php';

use Lazervel\MailSender\MailSender;

$mail = new MailSender(
  name: 'My App',
  email: 'youremail@gmail.com',
  password: 'yourpassword'
);

// Single recipient
$mail->addMail('John Doe', 'john@example.com');
$mail->mail->Subject = 'Welcome!';
$mail->mail->Body    = '<h1>Hello John!</h1><p>Welcome to our app.</p>';

// Send
if ($mail->send()) {
  echo "Mail sent successfully!";
} else {
  echo "Failed to send mail!";
}

📧 Multiple Recipients Example

$recipients = [
  [
    'name'  => 'User One',
    'email' => 'user1@example.com',
    'subject' => 'Hello!',
    'body' => '<p>This is a test email.</p>'
  ],
  [
    'name'  => 'User Two',
    'email' => 'user2@example.com',
    'subject' => 'Another Mail',
    'body' => '<p>This is another email.</p>'
  ]
];

$mail->sendTo($recipients)->send();

🖇️ Attachments

From File Path:

$mail->addAttachment('/path/to/file.pdf');

From Uploaded File ($_FILES):

$mail->addTmpFileAttachment($_FILES['file']);

From Base64 or URL:

$mail->addStringAttachment($dataUrl, 'document.pdf');

🎨 Inline CSS & Images

If your HTML contains linked CSS or image paths:

<link rel="stylesheet" href="style.css">
<img src="logo.png">

They will automatically be converted into inline <style> blocks and embedded CID images in the final email.

⚙️ Environment Variables (Optional)

You can define these in your .env file or system environment:

MAILER_NAME="My App"
MAILER_EMAIL="youremail@gmail.com"
MAILER_PASSWORD="yourpassword"
APP_NAME="My App"

🧱 Directory Structure

MailSender/
├── composer.json
├── README.md
├── src/
│   ├── MailSender.php
│   └── Exception/
│       └── ConfigurationException.php
└── tests/
    └── MailSenderTest.php

🧪 Testing

vendor/bin/phpunit

📜 License

This project is open-sourced under the MIT License.
Feel free to use, modify, and distribute with attribution.

❤️ Author

Afsara
Developer & Founder — Lazervel
GitHubEmail

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固