PHP code example of bjnstnkvc / mail-components

1. Go to this page and download the library: Download bjnstnkvc/mail-components 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/ */

    

bjnstnkvc / mail-components example snippets


/**
 * Create a new message instance.
 */
public function __construct()
{
    $this->theme = 'mail-components';
}

    'markdown' => [
        'theme' => 'mail-components',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

$headers = ['First Name', 'Last Name', 'Email'];
$columns = [
    ['John', 'Doe', '[email protected]'],
    ['Jane', 'Doe', '[email protected]'],
];

return view('welcome', [
    'users' => User::all();
]);

return view('welcome', [
    'users' => User::get([
        'first_name', 
        'last_name', 
        'email', 
        'email_verified_at as verified_at'
    ]);
]);

class VerificationMail extends Mailable
{
    /**
     * Create a new message instance.
     */
    public function __construct(public User $user, public string $email, public string $token)
    {
        // 
    }
    
    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            from   : new Address('[email protected]', 'Example'),
            subject: 'Verify Email',
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        return new Content(
            view: 'mail.verification-mail',
        );
    }
}
mail_components.php