PHP code example of kynetcode / wpzylos-mail

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

    

kynetcode / wpzylos-mail example snippets


use WPZylos\Framework\Mail\MailServiceProvider;

// In your plugin bootstrap
$app->register(new MailServiceProvider());

use WPZylos\Framework\Mail\Mailable;

$mail = new Mailable();
$mail->to('[email protected]')
    ->subject('Welcome!')
    ->greeting('Hello John!')
    ->line('Thanks for joining our platform.')
    ->action('Visit Dashboard', 'https://example.com/dashboard')
    ->line('We are happy to have you.')
    ->send();

use WPZylos\Framework\Mail\Mailable;

$mail = new Mailable();
$mail->to('[email protected]')
    ->cc('[email protected]')
    ->bcc('[email protected]')
    ->from('[email protected]', 'My Plugin')
    ->replyTo('[email protected]')
    ->subject('Your Weekly Report')
    ->greeting('Hi Sarah!')
    ->line('Here is your weekly activity report.')
    ->line('You completed 12 tasks this week.')
    ->action('View Full Report', 'https://example.com/report')
    ->line('Keep up the great work!')
    ->attach('/path/to/report.pdf')
    ->send();

use WPZylos\Framework\Mail\MailManager;

$mailManager = $app->make(MailManager::class);

// Set global defaults
$mailManager->setFrom('[email protected]', 'My Plugin');

// Send with defaults pre-applied
$mailManager->to('[email protected]')
    ->subject('Order Confirmed')
    ->view('emails.order-confirmed', ['order' => $order])
    ->attach('/path/to/invoice.pdf')
    ->send();

$mail = new Mailable();
$mail->to('[email protected]')
    ->subject('Custom HTML')
    ->html('<h1>Hello!</h1><p>This is a custom HTML email.</p>')
    ->send();

$mail = new Mailable();
$mail->to('[email protected]')
    ->subject('Plain Text')
    ->text('Hello! This is a plain text email.')
    ->send();

$mail = new Mailable();
$mail->to('[email protected]')
    ->subject('Invoice #1234')
    ->templatePath('/path/to/templates')
    ->view('invoice', [
        'customer' => $customer,
        'items'    => $items,
        'total'    => '$99.00',
    ])
    ->send();

$mail = new Mailable();
$mail->to('[email protected]')
    ->subject('Priority Message')
    ->header('X-Priority', '1')
    ->header('X-Mailer', 'WPZylos Mail')
    ->line('This is an important message.')
    ->send();

$mail = new Mailable();
$mail->to('[email protected]')
    ->subject('Test Email')
    ->greeting('Hello!')
    ->line('This is a test.');

$built = $mail->build();
// $built = [
//     'to'          => ['[email protected]'],
//     'subject'     => 'Test Email',
//     'message'     => '...html...',
//     'headers'     => ['Content-Type: text/html; charset=UTF-8'],
//     'attachments' => [],
// ]