PHP code example of yidas / socket-mailer

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

    

yidas / socket-mailer example snippets


$mailer = new \yidas\socketMailer\Mailer([
    'host' => 'mail.your.com',
    'username' => '[email protected]',
    'password' => 'passwd',
    ]);

$result = $mailer
    ->setSubject('Mail Title')
    ->setBody('Content Text')
    ->setTo(['[email protected]', '[email protected]' => 'Peter'])
    ->setFrom(['[email protected]' => 'Service Mailer'])
    ->setCc(['[email protected]' => 'CC Receiver'])
    ->setBcc(['[email protected]'])
    ->send();



use \yidas\socketMailer\Mailer;

$mailer = new \yidas\socketMailer\Mailer()

$mailer = new \yidas\socketMailer\Mailer([
    'host' => 'mail.your.com',
    'username' => '[email protected]',
    'password' => 'passwd',
    'port' => 587,
    'encryption' => 'tls',
    ]);

$mailer = new \yidas\socketMailer\Mailer([
    // ...
    'port' => 465,
    'encryption' => 'ssl',
    ]);

$mailer = new \yidas\socketMailer\Mailer([
    'host' => 'mail.your.com',
    'port' => 25,
    ]);

public self debugOn()

public self setFrom(string|array $form) 

public self setTo(array $recipients) 

public self setCc(array $recipients) 

public self setBcc(array $recipients) 

public self setBody(string $text) 

public self setSubject(string $title) 

public self addHeader($key, $value) 

$mailer = $mailer->addHeader('Your-Header-Name', 'the header value');

public boolean send()