PHP code example of ouranoshong / php-mailer

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

    

ouranoshong / php-mailer example snippets




$transport = new \Ouranoshong\Mailer\SMTPTransport(
    [
        'host' => 'smtp.gmail.com',
        'port' => 465,
        'encryption' => 'ssl',
        'username' => 'your username',
        'password' => 'your password'
    ]
);

$mailer = new \Ouranoshong\Mailer\Mailer($transport);
$mailer->setFrom('[email protected]')
    ->setTo('[email protected]')
    ->setSubject('subject')
    ->setText('email from php mailer')
    ->send();


$transport = new \Ouranoshong\Mailer\SMTPTransport(
    [
        'host' => 'smtp.gmail.com',
        'port' => 465,
        'encryption' => 'ssl',
        'username' => 'your username',
        'password' => 'your password',
        
        'httpProxy' => 'http://proxy.com:8080' //use http proxy
    ]
);

$mailer = new \Ouranoshong\Mailer\Mailer($transport);
$mailer->setFrom('[email protected]')
    ->setTo('[email protected]')
    ->setSubject('subject')
    ->setText('email from php mailer')
    ->send();
shell
composer