shepherdmat / emaillabs-symfony-mailer
This bundle provides Emaillabs integration for Symfony Mailer
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bridge
Requires
- php: >=7.4
- symfony/mailer: ^4.4
Requires (Dev)
- ext-json: *
- phpunit/phpunit: 9.5.x-dev
- symfony/http-client: ^4.4|^5.0
This package is not auto-updated.
Last update: 2025-04-28 03:42:14 UTC
README
Provides Emaillabs integration for Symfony Mailer.
Installation
The preferred method of installation is via [Composer][]. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
composer require shepherdmat/emaillabs-symfony-mailer
Usage
Symfony project.
If you want to use it in your standard Symfony project, it's easy:
Add parameters to your local .env file:
# .env
MAILER_DSN=emaillabs://yourAppKey:yourSecretKey@yourActiveHostAccount.smtp
Update services.yaml
# config/services.yaml services: Shepherdmat\Symfony\Mailer\Emaillabs\Transport\EmaillabsTransportFactory: tags: [ 'mailer.transport_factory' ]
Now you can follow example from official Symfony Mailer site.
Standalone mailer.
If you want to send email using standard SymfonyHttpClient as http interface:
// require_once __DIR__ . './vendor/autoload.php'; use Shepherdmat\Mailer\Emaillabs\Transport\EmaillabsApiTransport; use Shepherdmat\Mailer\Emaillabs\Transport\EmaillabsTransportFactory; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mime\Email; // Your active host account (https://panel.emaillabs.net.pl/pl/smtp). $host = 'YOUR_ACCOUNT.smtp'; // Your App Key (https://panel.emaillabs.net.pl/pl/site/api). $appKey = 'XXXXXXX'; // Your Secret Key (https://panel.emaillabs.net.pl/pl/site/api). $appSecret = 'YYYYYYY'; $transportFactory = new EmaillabsTransportFactory(null, HttpClient::create()); $dsn = new Dsn(EmaillabsTransportFactory::SCHEME, $host, $appKey, $appSecret); $mailer = new Mailer($transportFactory->create($dsn)); $message = (new Email()) ->from('foo@bar.dev') ->to('bar@foo.dev') ->subject('Message title') ->html('<b>HTML message content</b>') ->text('Text message content') // Attachments are handled by default. ->attachFromPath('./path/to/attachment') ->embedFromPath('./path/to/attachment', 'embed_tag'); // If you want to pass some api parameters, use dedicated headers. // (https://dev.emaillabs.io/#api-Send-new_sendmail) $message->getHeaders() // Comma-separated list of tags. ->addTextHeader(EmaillabsApiTransport::HEADER_TAGS, 'tag1,tag2,tag3') // Custom template ID. ->addTextHeader(EmaillabsApiTransport::HEADER_TEMPLATE, 'template_id') // Custom return path. ->addTextHeader(EmaillabsApiTransport::HEADER_RETURN_PATH, 'return_path'); $mailer->send($message);
License
This bundle is under the MIT license.
For the whole copyright, see the LICENSE file distributed with this source code.