h4kuna/mail-manager

该软件包已被废弃且不再维护。未建议替代软件包。

提供发送和开发电子邮件。

v1.3.0 2019-09-25 13:02 UTC

This package is auto-updated.

Last update: 2023-02-09 07:04:40 UTC


README

MailManager

Build Status Latest stable Downloads this Month Scrutinizer Code Quality Coverage Status

此扩展适用于 Nette 框架 2.4+。支持测试邮件。

项目安装

$ composer require h4kuna/mail-manager

使用方法

添加到 NEON 文件

extensions:
    mailManagerExtension: h4kuna\MailManager\DI\MailManagerExtension

mailManagerExtension:
    from: default@example.com
    templateDir: %appDir%/template # home for mail template
    debugMode: %debugMode% # enable FileMailer whose save email to file
    tempDir: %tempDir%/mail # where save email to file
    
    # optional
	plainMacro: # where will find email like plain text alternative default: '=file=-plain'
    assetsDir: # path to assets
    returnPath: # where back mail whose send non exists mail
    messageFactory: # prepare for Message instance
	globalVars: # global variables for all templates
		foo: bar
		bar: %variable%

    # development    
    live: FALSE # how long live email file in temp directory
        # - FALSE - forever
        # - '+1 minute' - relative time (default)

支持纯文本和 HTML 的不同模板。

$message = $mailer->createMessage('body', ['foo' => $foo, 'bar' => $bar]);

// if you have body.latte (for html) and body-plain.latte (for plain text) in same directory, then is used. And bind variables onetime.

$mailer->send($message);

$templateDir/test-file.latte 中准备 latte 文件。

<strong>variable foo has value:</strong> {$foo}

发送邮件。

/* @var $mailer h4kuna\MailManager\MailManager */
$message = $mailer->createMessage('test-file', ['foo' => 'bar'])
           ->addTo('Milan Matejcek <milan.matejcek@gmail.com>');
/* @var $message Nette\Mail\Message */
$message->addBcc('bar@example.com'); // avaible is 'mail' or 'name <mail>'
$mailer->send($message); // if anything bad throw exception

功能

  • 将电子邮件显示为 HTML 页面
  • 在开发机器上默认保存到文件
  • 自动删除已保存的邮件
  • 如果路径名称包含单词 plain,则将纯文本邮件设置为发送
  • 解析系统邮件并发送,如果您未在服务器上安装 sendmail