定制 ionvv/wp-mail-helper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ionvv/wp-mail-helper

Composer 安装命令:

composer require ionvv/wp-mail-helper

包简介

PHP package to send custom emails with WordPress.

README 文档

README

WP Mail Helper is a package to help WordPress developers to send custom emails.

Getting Started

Minimum requirements and dependencies

WP Mail Helper requires:

  • PHP 7+
  • WordPress - latest
  • Composer to be installed

Installation

Install via composer

composer require ionvv/wp-mail-helper

Usage

Basic usage

$email_controller = new \WpMailHelper\Email();
$email_controller->sendEmail(
    'recipient@domain.tld', // $to
    'sender@domain.tld',    // $from
    'Email subject',        // $subject
    'Email content'         // $message
);

Advanced usage

$email_controller->sendEmail(
    'recipient@domain.tld', // $to
    'sender@domain.tld',    // $from
    'Email subject',        // $subject
    'Email content',        // $message
    'template',             // $message_type
    [],                     // $headers
    'john.doe@domain.tld',  // $cc
    'john.doe@domain.tld',  // $bcc
    [WP_CONTENT_DIR . '/uploads/dummy-file.zip']
);

Use a post as email content

$email_controller = new \WpMailHelper\Email();
$email_controller->sendEmail(
    'recipient@domain.tld', // $to
    'sender@domain.tld',    // $from
    'Email subject',        // $subject
    '$post->ID',            // $message
    'post'                  // $message_type
);

Use a custom template as email content

$email_controller = new \WpMailHelper\Email();
$email_controller->sendEmail(
    'recipient@domain.tld',                               // $to
    'sender@domain.tld',                                  // $from
    'Email subject',                                      // $subject
    get_stylesheet_directory() . '/emails/template.html', // $message
    'template'                                            // $message_type
);

Use custom variables in email content

Sometimes you'll have to replace some variables programatically in your emails. You can use the 'shortcodes' in the email subject and content. Check the following example to see how you can use them:

$email_subject = 'Welcome to our website, {{FIRST_NAME}}';
$email_content = 'Dear {{FIRST_NAME}}, thanks for joining our website. You have been registered with the following email address: {{EMAIL_ADDRESS}}';

$email_controller = new \WpMailHelper\Email();
$email_controller->setVars(
    [
        'FIRST_NAME' => 'Ion',
        'EMAIL_ADDRESS' => 'ion@domain.tld'
    ],
    [
        'FIRST_NAME' => 'Ion'
    ]
);
$email_controller->sendEmail(
    'ion@domain.tld',       // $to
    'sender@domain.tld',    // $from
    $email_subject,         // $subject
    $email_content          // $message
);

User will receive an email with the following subject:

Welcome to our website, Ion

and the content:

Dear Ion, thanks for joining our website. You have been registered with the following email address: ion@domain.tld

Changelog

1.0.0

  • Initial release

License

WP Mail Helper code is licensed under MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固