承接 programster/phpmailer-wrapper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

programster/phpmailer-wrapper

最新稳定版本:1.2.1

Composer 安装命令:

composer require programster/phpmailer-wrapper

包简介

A wrapper around PHPMailer to make it easier to use.

README 文档

README

This package makes it easier to send more advanced emails with PHPMailer.

If you just want to be able to send basic emails, using a variety of different possible drivers, you may be interested in the emailers package instead.

Install

One can install the package with Composer by running:

composer require programster/phpmailer-wrapper

Example Usage

Below is an example of how one may use this tool to send an invoice as an attachment in an email to another person, being sure to provide both an HTML message, and the plaintext alternative, in case any of the recipients cannot view HTML emails. In this example, we also CC the accounts email address.

<?php

use Programster\Phpmailer\Attachment;
use Programster\Phpmailer\AttachmentCollection;
use Programster\Phpmailer\Contact;
use Programster\Phpmailer\ContactCollection;
use Programster\Phpmailer\PhpMailerEmailer;
use Programster\Phpmailer\SecurityProtocol;

require_once(__DIR__ . '/vendor/autoload.php');

# Create the emailer. We can use this to send() any number of emails.
$mailer = new PhpMailerEmailer(
    smtpHost: 'smtp.gmail.com', 
    smtpUser: 'my.email@gmail.com', 
    smtpPassword: 'myPasswordGoesHere', 
    securityProtocol: SecurityProtocol::TLS,
    from: new \Programster\Phpmailer\Contact('myEmail@gmail.com', 'My Name'),
    smtpPort: 587
);

# Send an email
$mailer->send(
    subject: 'Latest Invoice',
    plaintextMessage: "Please find attached my latest invoice.",
    htmlMessage: "<p>Please find attached my latest invoice.</p>",
    to: new ContactCollection(new Contact("to.email@company.domain", "Client Name")),
    cc: new ContactCollection(new Contact("accounts@company.domain", "Accounts")),
    attachments: new AttachmentCollection(new Attachment(__DIR__ . '/invoice.pdf', "my-invoice.pdf"));
);

统计信息

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

GitHub 信息

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

其他信息

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