magento2-module magento2-module-mailattachment
Extends TransportBuilder with attachment functionality
weprovide/magento2-module-mailattachment
Extends TransportBuilder with attachment functionality
- Tuesday, June 13, 2017
- by timneutkens
- Repository
- 2 Watchers
- 6 Stars
- 1,856 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 3 Forks
- 0 Open issues
- 3 Versions
- 11 % Grown
Magento2 Module MailAttachment
Extends TransportBuilder with attachment functionality, (*1)
Installation
composer require weprovide/magento2-module-mailattachment
bin/magento setup:upgrade
Usage example
<?php
namespace YourNameSpace\YourModule\Controller\Email;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Area;
use Magento\Framework\Controller\ResultFactory;
use Magento\Store\Model\Store;
use WeProvide\MailAttachment\Mail\Template\TransportBuilder;
use Zend_Mime;
class Index extends Action
{
protected $transportBuilder;
public function __construct(
Context $context,
TransportBuilder $transportBuilder
) {
$this->transportBuilder = $transportBuilder;
parent::__construct($context);
}
/**
* Execute view action
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
// Any buffer
$content = '';
$transport = $this->transportBuilder->setTemplateIdentifier('example_identifier')
->setTemplateOptions([
'area' => Area::AREA_FRONTEND,
'store' => Store::DEFAULT_STORE_ID,
])
->setFrom([
'name' => 'Example name',
'email' => 'info@example.com',
])
->addTo('example@example.com')
->addAttachment($content, 'document.pdf', 'application/pdf');
$transport = $transport->getTransport();
$transport->sendMessage();
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}
Api
public function addAttachment(
$content,
$fileName = '',
$fileType = ''
)
, (*2)
For reference also check the code, (*3)
dev-master
9999999-dev
Extends TransportBuilder with attachment functionality
Sources
Download
MIT
by
Dwayne Hanekamp
1.0.1
1.0.1.0
Extends TransportBuilder with attachment functionality
Sources
Download
MIT
by
Dwayne Hanekamp
1.0.0
1.0.0.0
Extends TransportBuilder with attachment functionality
Sources
Download
MIT
by
Dwayne Hanekamp