h4kuna / mail-manager
Provide send and development email.
Installs: 9 161
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- latte/latte: ~2.4
- nette/application: ~3.0
- nette/mail: ~3.0
- nette/schema: ~1.0
- nette/utils: ~3.0
Requires (Dev)
- nette/bootstrap: ~3.0
- phpstan/phpstan: ~0.11
- salamium/testinium: ^0.1
README
MailManager
This extension for Nette framework 2.4+. Support testing mails
Installation to project
$ composer require h4kuna/mail-manager
How to use
Add to your file 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)
Support different templates for plain text and for 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);
Prepare latte file in $templateDir/test-file.latte
<strong>variable foo has value:</strong> {$foo}
Send mail.
/* @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
Features
- display email as html page
- on development machine default save to file
- autoremove saved email
- if path name containt word plain, than set plain text mail to send
- parse system mail and send, if you haven't installed sendmail on server