shadiakiki1986/swiftmailer-wrapper

1.0.2 2017-08-30 11:31 UTC

This package is auto-updated.

Last update: 2024-09-27 02:16:27 UTC


README

用于使用 Swiftmailer (在 php 中) 的包装函数

可在 packagist 上找到

安装: composer require shadiakiki1986/swiftmailer-wrapper:dev-master

使用

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

\SwiftmailerWrapper\Utils::mail_attachment(

  // attachments
  array("/path/to/file1","/path/to/file2"),

  // to, from, reply emails
  "to@email.com",
  "from@email.com",
  "From Name",
  "reply@email.com",

  // subject, body
  "This is a subject",
  "This is a message. It <i>supports</i> html.",

  // config array
  array(
    "host"=>"smtp.server.com",
    "port"=>"123",
    "username"=>"myUser",
    "password"=>"pizza"
  )

);

可以通过以下方式将文件重命名,通过传递文件参数如下

  array("newName1"=>"/path/to/file1","newName2"=>"/path/to/file2"),

要使用 加密 SMTP,向配置数组中添加 security 键。有效值是:false, ssl, tls

要添加备用 SMTP 服务器和凭证,添加一个类似于原始配置数组的 backup 键,即包含 host, port, username, password, security

测试

composer install
SWIFTMAILER_WRAPPER_EML1=my@gmail.com \
  SWIFTMAILER_WRAPPER_PWD1=password1 \
  SWIFTMAILER_WRAPPER_EML2=another@gmail.com \
  SWIFTMAILER_WRAPPER_PWD2=password2 \
  composer test

注意,上述电子邮件应该是 Gmail 账户,因为测试明确定义了 Gmail 服务器