Documentation
- Installation
- Controller
- Views
- Database access
- Modules
- Autoloading
- Config management
- Localization
- Logging
- Environment
- Helpers
- Exceptions
- CLI interface
- Events
- Commands
- Authentication
- Caching
- Testing
- mail() wrapper
- SMTP mailer
- HTML helpers
- npm/webpack
mail() wrapper
The framework comes with a convenience wrapper for the PHP inbuilt mail() function. It can be used to use views with templating as mail content.
The following example demonstrates how to use the functionality
<?php
//Instantiate class instance
$mailer = new Asatru\Mailwrapper\Mail();
//Here you set the recipient of the e-mail
$mailer->setRecipient('receiver@example.com');
//E-Mail subject
$mailer->setSubject('E-Mail subject');
//Specify a view
$mailer->setView('layout', array(array('yield', 'yieldfile')), [
'some_var' => $some_value
]);
//Or specifiy the content directly
$mailer->setMessage('Content goes here...');
//You can also optionally specify addition headers and parameters
$mailer->setAdditionalHeaders(headers);
$mailer->setAdditionalParameters(parameters);
$mailer->send(); //Send the e-mail