PHP code example of lemonade / email-generator

1. Go to this page and download the library: Download lemonade/email-generator 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/ */

    

lemonade / email-generator example snippets


use Lemonade\EmailGenerator\DefaultBuilder;
use Lemonade\EmailGenerator\DefaultContainerBuilder;
use Lemonade\EmailGenerator\DTO\AddressData;

r the footer
$addressService = $container->getAddressService(); // Fetch the AddressService from the container
$footerAddress = $addressService->getAddress(new AddressData([
    "addressCompanyId" => "CZ12345678",           // Company ID
    "addressCompanyVatId" => "CZ87654321",       // VAT ID
    "addressCompanyName" => "Firma XYZ",         // Company name
    "addressAlias" => "Sídlo",                   // Address alias
    "addressName" => "Josef Novák",              // Contact person name
    "addressStreet" => "Ulice 1234/56",          // Street address
    "addressPostcode" => "12345",                // Postal code
    "addressCity" => "Praha",                    // City
    "addressCountry" => "CZ",                    // Country code
    "addressPhone" => "+420 123 456 789",        // Contact phone
    "addressEmail" => "[email protected]"       // Contact email
]));

// Step 3: Use DefaultBuilder to construct the email
$builder = new DefaultBuilder($container);

// Step 4: Build the email content
echo $builder
    ->addHeader("Password Reset")                           // Add a header with the title "Password Reset"
    ->componentLostPassword("Your Website", "https://example.com/reset-password") // Add a block for password reset with the website name and reset link
    ->addFooter($footerAddress)                             // Add a footer with the previously created address
    ->build();                                              // Build and output the final email HTML