PHP code example of mabasic / mailer

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

    

mabasic / mailer example snippets


$this->contactMailer->send($data);

Mail::queue($view, $data, function($message) use($email, $subject)
{
    $message->to($email)->subject($subject);
});

 namespace Acme\Mailers;

use Mabasic\Mailer\Mailer;

class ContactMailer extends Mailer {

    public function send($data)
    {
        $view = 'emails.contact';
        $subject = 'Test';
        $email = '[email protected]';

        $this->sendTo($email, $subject, $view, $data);
    }

}



use Acme\Mailers\ContactMailer;

class MailerController extends \BaseController {

    protected $contactMailer;

    function __construct(ContactMailer $contactMailer)
    {
        $this->contactMailer = $contactMailer;
    }

    public function sendMail()
    {
        // Get some data for the email, like user name, message, etc ...

        $data = [
            'name' => 'John Doe',
            'comment' => 'Hello, nice to meet you.'
        ];

        $this->contactMailer->send($data);

        return 'ok';
    }

}