PHP code example of flysend / flysend-laravel
1. Go to this page and download the library: Download flysend/flysend-laravel 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/ */
flysend / flysend-laravel example snippets
'mailers' => [
// ...
'flysend' => [
'transport' => 'flysend',
],
],
use Illuminate\Support\Facades\Mail;
// Simple email
Mail::raw('Hello world!', function ($message) {
$message->from('[email protected] ');
$message->to('[email protected] ');
$message->subject('Hello');
});
// Mailable
Mail::to('[email protected] ')->send(new WelcomeMail());
class WelcomeMail extends Mailable
{
public function build()
{
return $this->subject('Welcome!')
->html('<p>Welcome aboard!</p>')
->withSymfonyMessage(function ($message) {
$message->getHeaders()->addTextHeader(
'X-FlySend-Tags',
json_encode([
['name' => 'campaign', 'value' => 'welcome'],
])
);
});
}
}
use FlySend\Laravel\Facades\FlySend;
$response = FlySend::send([
'from' => '[email protected] ',
'to' => '[email protected] ',
'subject' => 'Welcome!',
'html' => '<p>Hello world!</p>',
'text' => 'Hello world!',
'reply_to' => '[email protected] ',
'tags' => [
['name' => 'campaign', 'value' => 'welcome'],
['name' => 'user_id', 'value' => '12345'],
],
'attachments' => [
[
'filename' => 'invoice.pdf',
'content' => base64_encode($pdfContent),
'mime_type' => 'application/pdf',
],
],
]);
// $response['data']['id'] contains the email ID
bash
php artisan vendor:publish --tag=flysend-config