PHP code example of dframe / mymail

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

    

dframe / mymail example snippets


use \Dframe\MyMail\MyMail;

fig/config.php'; 
$MyMail = new MyMail($config);                                       // Load Config
$addAddress = ['mail' => 'adres@email', 'name' => 'Title From']; // Addresses to send
$MyMail->send($addAddress, 'Test Mail', $body);



use Dframe\MyMail\MyMail;

nfig.php'; 

$MyMail = new MyMail($config); // Załadowanie Configu
$MyMail->mail->isSMTP();
$MyMail->mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
//$MyMail->SMTPDebug  = 2; // Enables SMTP debug information (for testing)
                         // 1 = errors and messages
                         // 2 = messages only
$MyMail->mail->SMTPSecure = false;

$addAddress = ['mail' => 'adres@email', 'name' => 'titleFrom']; // Addresses to send

try {
    $MyMail->send($addAddress, 'Test Mail', 'Hello Word!');

} catch (Exception $e) {
    echo $e->getMessage();
	
}



use Dframe\MyMail\MyMail;
use Dframe\Component\Config\Config;
$view = $this->loadView('index');
$MyMail = new MyMail(Config::load('myMail')->get()); // Load Configu

/* 
 * If you have problem with ssl in php 5.6 add
 *       $MyMail->SMTPOptions = [
 *           'ssl' => [
 *               'verify_peer' => false,
 *               'verify_peer_name' => false,
 *               'allow_self_signed' => true
 *           ]
 *       ];
 */
 
 $MyMail->SMTPDebug  = 2; // Enables SMTP debug information (for testing)
                          // 1 = errors and messages
                          // 2 = messages only
		       
$addAddress = ['mail' => $_POST['email'], 'name' => $_POST['firstname']];    // Addresses to send
$view->assign('name', $_POST['firstname']);                                       // Assign template values
$body = $view->fetch('reset');                                                    // Template mail
$MyMail->send($addAddress, 'Test Mail', $body);