gabriel-binotti/email 问题修复 & 功能扩展

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

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

gabriel-binotti/email

最新稳定版本:1.0.0

Composer 安装命令:

composer require gabriel-binotti/email

包简介

Simple example to send email with phpmailer

README 文档

README

Require

  • PHP >= 7.0
  • Composer installed
  • A server mail

Install

You can install this class using the line-command

composer require gabriel-binotti/email

Step 0

You need config the file email.ini in vendor/appEmail/config/email.ini

host = nameserve
username = user
password = password
auth = 'true' or 'false'
port = 587 or 465
charset = 'UTF-8'
secure = 'false' or 'true'

After you can to use that class by examples above.

index.php

use GabrielBinottiEmail\Email;

require_once "vendor/autoload.php";

try {

    Email::email('email')                       // name file .ini
        ->debug()                               // active show debug (server, client or off "default is off")
        ->from("email", "name")                 // sender's email , name (Can your name or you company...)
        ->reply("email", "name ")               // answer email (optional)
        ->destination("email", 'name')          // recipient email , name
        ->subject("subject email")              // subject email
        ->bodyHtml('text body')                 // text body
        ->options([
            "ssl" => [
                'verify_peer'       => false,   
                'verify_peer_name'  => false,   
                'allow_self_signed' => true    
            ]
        ])
        ->send();                               // send email
        
} catch (Exception $e) {
    echo $e->getMessage();
}

options() is configured based in your server if they have SSL or not.

You can to use template HTML in body email, change bodyHtml() to template()

    template('template.html');                    

The template you create in vendor/appEmail/template/, by default the second parameter ir an array empty, but you can send an array to replace.

$arrayReplace = [
    [
        "before" => "value",
        "after" => "value",
    ],
    [
        "before" => "value",
        "after" => "value",
    ]
];

 template('template.html', $arrayReplace);

You can send file in you email. You need add file in vendor/appEmail/files/

addFile("filename.format", "name file");

You can add image in your body. Add the image in vendor/appEmail/images/

addImage("image.format", "name image");

To add image in your body email, you need create a template, example above:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <img src="cid:nameImage" alt="">
</body>
</html>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-03-27