PHP code example of zein / mail

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

    

zein / mail example snippets




use Zein\Mail\{Factory, Template};

private $Dsn = 'gmail+smtp://<youremail>:<password>@default';
    //private $Dsn = 'ssl://smtp.gmail.com:465,<youremail>.com,<password>,465,465,0';
    private $Agent = 'Symfony\Mailer\Mailer';
    //private $Agent = 'Phpmailer\Phpmailer\Mailer';
    private $Contents;

    /**
     * Get template agent
     */
    public function getAgent()
    {
        return $this->Agent;
    }

    public function getDsn()
    {
        return $this->Dsn;
    }

    public function getContents()
    {
        return $this->Contents;
    }

    public function baspus()
    {
        $Agent = $this->getAgent();
        $this->Contents = <<<HTML
            <h1>Lorem Ipsum {$Agent}</h1>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
        HTML;
    }

    /**
     * Set template agent
     */
    public function setAgent(string $agentName)
    {
        $this->Agent = $agentName;
    }
}

$Factory = new Factory(new IttpMail);
$Mail = $Factory->getMail();
$Mail->compose(['mailAddress' => '<sender>', 'label' => 'Mail Test'], '<receiver>', 'SMTP Outgoing Test');
$Mail->send('baspus'); // send email based on template method

var_dump($Mail->getError());