PHP code example of g4 / mailer

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

    

g4 / mailer example snippets


 

// Config data
$options = [
    'delivery' => "smtp",
    'adapter'  => "smtp",
    'params'   => [
        'host'              => "smtp.example.com",
        'port'              => "587",
        'connection_class'  => "plain",
        'connection_config' => [
            'ssl'      => "tls",
            'username' => "smtp_username",
            'password' => "smtp_password"
        ]
    ]
];

// Create message
$message = new \G4\Mailer\Message(
    '[email protected]',
    '[email protected]',
    'Email subject',
    'This is a <strong>html</strong> email part',
    'This is a text email part'
);

// Create mailer instance
$mailer = \G4\Mailer\Mailer::factory($options);

// send message
$mailer->send($message);