PHP code example of shepherdmat / emaillabs-symfony-mailer
1. Go to this page and download the library: Download shepherdmat/emaillabs-symfony-mailer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shepherdmat / emaillabs-symfony-mailer example snippets
// se 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('[email protected]')
->to('[email protected]')
->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);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.