<commit_before>A CodeIgniter compatible email-library powered by PHPMailer
===========================================================

Author: <NAME> <<EMAIL>>, 2012-2013.
License: The MIT License (MIT), http://opensource.org/licenses/MIT

Tested on with codeIgniter_2.1.4, CodeIgniter 3.0-dev (July 2013) and PHPMailer Version 5.2.1 (January 16, 2012).

Installation
------------

Download this package and uncompress it within `application/` directory of your CodeIgniter site.


Download and uncompress PHPMailer `application/third_party/phpmailer/` directory. For security reasons remove unused folders and files: docs, examples, extras, test, and etc.

Links:

http://phpmailer.worxware.com/

https://github.com/Synchro/PHPMailer

Setting It Up (Example)
-----------------------

1. Edit the file `application/config/email.php` which contains the default settings for the email engine. For a Gmail account, the setting might be something like this:

```php
<?php defined('BASEPATH') OR exit('No direct script access allowed.');

$config['useragent']        = 'PHPMailer';              // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol']         = 'smtp';                   // 'mail', 'sendmail', or 'smtp'
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = 'smtp.gmail.com';
$config['smtp_user']        = '<EMAIL>';
$config['smtp_pass']        = '<PASSWORD>';
$config['smtp_port']        = 465;
$config['smtp_timeout']     = 5;                        // (in seconds)
$config['smtp_crypto']      = 'ssl';                    // '' or 'tls' or 'ssl'
$config['wordwrap']         = true;
$config['wrapchars']        = 76;
$config['mailtype']         = 'html';                   // 'text' or 'html'
$config['charset']          = 'utf-8';
$config['validate']         = true;
$config['priority']         = 3;                        // 1, 2, 3, 4, 5
$config['crlf']             = "\n";                     // "\r\n" or "\n" or "\r"
$config['newline']          = "\n";                     // "\r\n" or "\n" or "\r"
$config['bcc_batch_mode']   = false;
$config['bcc_batch_size']   = 200;
```

Notes:
- PHP openssl module should be enabled if encrypted SMTP access is required;
- Set $config['useragent'] as 'PHPMailer' if the original 'CodeIgniter' engine fails for some reason.

2. Within a controller paste the following code for testing purposes:

```php
            $this->load->library('email');

            $subject = 'This is a test';
            $message = '<p>This message has been sent for tesing purposes.</p>';

            // Get full html:
            $body =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>'.htmlspecialchars($subject, ENT_QUOTES, $this->email->charset).'</title>
    <style type="text/css">
        body {
            font-family: Arial, Verdana, Helvetica, sans-serif;
            font-size: 16px;
        }
    </style>
</head>
<body>
'.$message.'
</body>
</html>';
            // Also, for getting full html you may use the following internal method:
            //$body = $this->email->full_html($subject, $message);

            $this->email
                ->from('<EMAIL>')
                ->reply_to('<EMAIL>')    // Optional, an account where a human being reads.
                ->to('<EMAIL>')
                ->subject($subject)
                ->message($body)
                ->send();

            echo $this->email->print_debugger();

            exit;
```

Load the corresponding page, executte this code. Check whether an email has been sent. Read the error message, if any, and make corrections in your settings.

Note, that most of the SMTP servers require "from" address of the message to be the same as the address within $config['smtp_user'] setting.<commit_msg>A minor correction within README.md.<commit_after>A CodeIgniter compatible email-library powered by PHPMailer
===========================================================

Author: <NAME> <<EMAIL>>, 2012-2013.
License: The MIT License (MIT), http://opensource.org/licenses/MIT

Tested on with codeIgniter_2.1.4, CodeIgniter 3.0-dev (July 2013) and PHPMailer Version 5.2.1 (January 16, 2012).

Installation
------------

Download this package and uncompress it within `application/` directory of your CodeIgniter site.


Download and uncompress PHPMailer `application/third_party/phpmailer/` directory. For security reasons remove unused folders and files: docs, examples, extras, test, and etc.

Links:

http://phpmailer.worxware.com/

https://github.com/Synchro/PHPMailer

Setting It Up (Example)
-----------------------

1. Edit the file `application/config/email.php` which contains the default settings for the email engine. For a Gmail account, the setting might be something like this:

```php
<?php defined('BASEPATH') OR exit('No direct script access allowed.');

$config['useragent']        = 'PHPMailer';              // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol']         = 'smtp';                   // 'mail', 'sendmail', or 'smtp'
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = 'smtp.gmail.com';
$config['smtp_user']        = '<EMAIL>';
$config['smtp_pass']        = '<PASSWORD>';
$config['smtp_port']        = 465;
$config['smtp_timeout']     = 5;                        // (in seconds)
$config['smtp_crypto']      = 'ssl';                    // '' or 'tls' or 'ssl'
$config['wordwrap']         = true;
$config['wrapchars']        = 76;
$config['mailtype']         = 'html';                   // 'text' or 'html'
$config['charset']          = 'utf-8';
$config['validate']         = true;
$config['priority']         = 3;                        // 1, 2, 3, 4, 5
$config['crlf']             = "\n";                     // "\r\n" or "\n" or "\r"
$config['newline']          = "\n";                     // "\r\n" or "\n" or "\r"
$config['bcc_batch_mode']   = false;
$config['bcc_batch_size']   = 200;
```

Notes:
- PHP openssl module should be enabled if encrypted SMTP access is required;
- Set $config['useragent'] as 'PHPMailer' if the original 'CodeIgniter' engine fails for some reason.

2. Within a controller paste the following code for testing purposes:

```php
            $this->load->library('email');

            $subject = 'This is a test';
            $message = '<p>This message has been sent for tesing purposes.</p>';

            // Get full html:
            $body =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>'.htmlspecialchars($subject, ENT_QUOTES, $this->email->charset).'</title>
    <style type="text/css">
        body {
            font-family: Arial, Verdana, Helvetica, sans-serif;
            font-size: 16px;
        }
    </style>
</head>
<body>
'.$message.'
</body>
</html>';
            // Also, for getting full html you may use the following internal method:
            //$body = $this->email->full_html($subject, $message);

            $result = $this->email
                ->from('<EMAIL>')
                ->reply_to('<EMAIL>')    // Optional, an account where a human being reads.
                ->to('<EMAIL>')
                ->subject($subject)
                ->message($body)
                ->send();

            var_dump($result);
            echo '<br />';
            echo $this->email->print_debugger();

            exit;
```

Load the corresponding page, executte this code. Check whether an email has been sent. Read the error message, if any, and make corrections in your settings.

Note, that most of the SMTP servers require "from" address of the message to be the same as the address within $config['smtp_user'] setting.
{'fraction_non_alphanumeric': 0.17000124269914255, 'fraction_numerical': 0.014415310053436063, 'mean_word_length': 2.4072819644369177, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 78, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4371590', 'n_tokens_mistral': 2539, 'n_tokens_neox': 2342, 'n_words': 711}