ahmedrady255/email-template-manager 问题修复 & 功能扩展

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

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

ahmedrady255/email-template-manager

Composer 安装命令:

composer require ahmedrady255/email-template-manager

包简介

this package is made to provide templates for different types

README 文档

README

A Laravel package for managing email templates with built-in SMTP configuration.

Features

  • Manage and customize email templates.
  • Send emails with different types using predefined templates.
  • Simple SMTP configuration and integration.
  • Easy-to-use API for sending emails.

Installation

1. Install the Package

You can install the package via Composer:

composer require ahmedrady255/email-template-manager

3. Install SMTP Configuration (Optional)

Run the SMTP installation command to set up default SMTP settings:

php artisan email-template-manager:install-smtp

Configuration

SMTP Settings

The package uses SMTP for sending emails. You can configure the SMTP settings in your .env file or in the config/email_templates.php configuration file.

Example .env settings:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your-smtp-username
MAIL_PASSWORD=your-smtp-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=your-email@example.com
MAIL_FROM_NAME="${APP_NAME}"

Email Templates

Define and customize email templates in the resources/views/vendor/email-templates/ directory. By default, this directory contains the template files you can modify.

Example template:

resources/views/vendor/email-templates/welcome_email.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Welcome to Our Service</title>
</head>
<body>
    <h1>Hello {{ $name }},</h1>
    <p>Thank you for signing up for our service!</p>
    <p>Best regards,</p>
    <p>The Team</p>
</body>
</html>

Usage

Sending an Email

You can send email by add the service to your controller

Example Request:

<?php

namespace EmailTemplateManager\Http\Controllers;

use Illuminate\Http\Request;
use EmailTemplateManager\Services\EmailService;

class EmailController extends Controller
{
    protected $emailService;

    public function __construct(EmailService $emailService)
    {
        $this->emailService = $emailService;
    }

    public function sendEmail(Request $request)
    {
        $emailType = $request->input('email_type'); // Email type (welcome, order, etc.)
        $recipient = $request->input('email');
        $data = $request->all();

        $this->emailService->sendEmail($emailType, $data, $recipient);

        return response()->json(['message' => 'Email sent successfully.']);
    }
}

Testing

To ensure everything works correctly, you can run the package tests:

php artisan test

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Commit your changes.
  4. Push to the branch and create a pull request.

License

This package is licensed under the MIT License. See the LICENSE file for details.

Support

For issues or questions, please create an issue on GitHub Issues.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-15