PHP code example of ttek / tk-mail

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

    

ttek / tk-mail example snippets


$message = new \Tk\Mail\Message();
$message->addTo('[email protected]');
$message->setFrom('[email protected]');
$message->setSubject('This is a test email');
$message->setBody(\App\Config::createMailTemplate('This is some message text'));

$message->send();

/* Default config options */
$cfg = array();

/*
 * Options mail, smtp, sendmail, qmail
 */
$cfg['mail.driver'] = 'mail';

/*
 * SMTP settings
 */

/**
 * SMTP hosts.
 * Either a single hostname or multiple semicolon-delimited hostnames.
 * You can also specify a different port
 * for each host by using this format: [hostname:port]
 * (e.g. "smtp1.example.com:25;smtp2.example.com").
 * You can also specify encryption type, for example:
 * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
 * Hosts will be tried in order.
 * @var string
 */
$cfg['mail.smtp.host'] = 'localhost';
// The default SMTP server port.
$cfg['mail.smtp.port'] = 25;
$cfg['mail.smtp.username'] = '';
$cfg['mail.smtp.password'] = '';
// What kind of encryption to use on the SMTP connection. Options: '', 'ssl' or 'tls'
$cfg['mail.smtp.secure'] = '';
// Whether to use SMTP authentication. Uses the Username and Password properties.
$cfg['mail.smtp.enableAuth'] = true;
// Whether to keep SMTP connection open after each message. If this is set to true 
//   then to close the connection