1. Go to this page and download the library: Download getodden/mail 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/ */
getodden / mail example snippets
use Odden\MailBuilder\MailBuilder;
use Odden\MailBuilder\Enums\SlotType;
// Fluent EmailDocument API
$doc = MailBuilder::document(
subject: 'Welcome to the Platform, {{ contact.first_name }}!',
previewText: 'Get started with your new account in 3 easy steps.'
);
$doc->append(SlotType::Header, [
'brand_name' => 'Acme Corp',
'logo_url' => 'https://example.com/logo.png',
]);
$doc->append(SlotType::Hero, [
'title' => 'Accelerate Your Workflow',
'subtitle' => 'Everything you need to deliver world-class projects.',
'button_text' => 'Get Started',
'button_url' => 'https://example.com/onboarding',
]);
$doc->append(SlotType::TwoColumn, [
'left_title' => 'Cloud Infrastructure',
'left_body' => 'Deploy high-availability services across 30+ edge regions.',
'right_title' => 'RevOps Analytics',
'right_body' => 'Real-time pipeline tracking and automated revenue forecasting.',
'reverse_stack_on_mobile' => true,
]);
$doc->append(SlotType::AppBadges, [
'heading' => 'Download Our Mobile App',
'app_store_url' => 'https://apps.apple.com/app/acme',
'google_play_url' => 'https://play.google.com/store/apps/acme',
]);
$doc->append(SlotType::Footer, [
'company_name' => 'Acme Inc.',
'address' => '548 Market St, San Francisco, CA',
'unsubscribe_url' => '{{ unsubscribe_url }}',
]);
// Compile to responsive inlined HTML
$html = MailBuilder::compile($doc);
// Extract plain text fallback
$plainText = MailBuilder::plainText($doc);
use Odden\MailBuilder\Mail\TemplateMailable;
use Illuminate\Support\Facades\Mail;
Mail::to('[email protected]')->send(
new TemplateMailable(
template: $doc,
data: [
'contact' => ['first_name' => 'Sarah'],
'unsubscribe_url' => 'https://example.com/unsubscribe/token',
],
subjectLine: 'Exclusive Offer for {{ contact.first_name }}',
embedCidImages: true // Embeds local & base64 images as MIME CID parts
)
);
use Odden\MailBuilder\Filament\Components\EmailSlotBuilder;
public static function form(Schema $schema): Schema
{
return $schema->components([
EmailSlotBuilder::make('slots'),
]);
}