{"id":13559968,"url":"https://github.com/ivantcholakov/codeigniter-phpmailer","last_synced_at":"2025-05-16T07:03:40.814Z","repository":{"id":9691062,"uuid":"11638432","full_name":"ivantcholakov/codeigniter-phpmailer","owner":"ivantcholakov","description":"A CodeIgniter 3 compatible email-library powered by PHPMailer","archived":false,"fork":false,"pushed_at":"2023-07-20T10:07:39.000Z","size":1187,"stargazers_count":255,"open_issues_count":0,"forks_count":290,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-05-08T21:35:38.969Z","etag":null,"topics":["codeigniter","php","phpmailer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivantcholakov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-07-24T15:34:48.000Z","updated_at":"2024-11-19T12:05:34.000Z","dependencies_parsed_at":"2024-01-13T12:33:00.915Z","dependency_job_id":null,"html_url":"https://github.com/ivantcholakov/codeigniter-phpmailer","commit_stats":null,"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantcholakov%2Fcodeigniter-phpmailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantcholakov%2Fcodeigniter-phpmailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantcholakov%2Fcodeigniter-phpmailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivantcholakov%2Fcodeigniter-phpmailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivantcholakov","download_url":"https://codeload.github.com/ivantcholakov/codeigniter-phpmailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485052,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeigniter","php","phpmailer"],"created_at":"2024-08-01T13:00:35.601Z","updated_at":"2025-05-16T07:03:40.756Z","avatar_url":"https://github.com/ivantcholakov.png","language":"PHP","readme":"[![Latest Stable Version](https://poser.pugx.org/ivantcholakov/codeigniter-phpmailer/v)](//packagist.org/packages/ivantcholakov/codeigniter-phpmailer)\n[![Total Downloads](https://poser.pugx.org/ivantcholakov/codeigniter-phpmailer/downloads)](//packagist.org/packages/ivantcholakov/codeigniter-phpmailer)\n[![Latest Unstable Version](https://poser.pugx.org/ivantcholakov/codeigniter-phpmailer/v/unstable)](//packagist.org/packages/ivantcholakov/codeigniter-phpmailer)\n[![License](https://poser.pugx.org/ivantcholakov/codeigniter-phpmailer/license)](//packagist.org/packages/ivantcholakov/codeigniter-phpmailer)\n\nA CodeIgniter compatible email-library powered by PHPMailer\n===========================================================\n\nVersion: 1.5.0  \nAuthor: Ivan Tcholakov \u003civantcholakov@gmail.com\u003e, 2012-2022.  \nLicense: The MIT License (MIT), http://opensource.org/licenses/MIT\n\nThis library is compatible with CodeIgniter 3.1.x and PHP \u003e= 7.3.0.\n\nTested on CodeIgniter 3.1.13 (March 3rd, 2022) and PHPMailer Version 6.6.4 (August 22nd, 2022).\n\nLinks\n-----\n\nPackage: https://packagist.org/packages/ivantcholakov/codeigniter-phpmailer\n\nPHPMailer: https://github.com/PHPMailer/PHPMailer\n\nInstallation\n------------\n\nEnable Composer to be used by CodeIgniter. Check this page from its documentation:\nhttps://www.codeigniter.com/userguide3/general/autoloader.html .\nYou need to see or decide when your vendor/ directory is (to be) and within the\nCodeIgniter's configuration file application/config/config.php you need to set the\nconfiguration option $config['composer_autoload'] accordingly. For the typical location\napplication/vendor/ the configuration setting would look like this:\n\n```php\n$config['composer_autoload'] = APPPATH.'vendor/autoload.php';\n```\n\nWithin application/config/constants.php add the following lines:\n\n```php\n// Path to Composer's vendor/ directory, it should end with a trailing slash.\ndefined('VENDORPATH') OR define('VENDORPATH', rtrim(str_replace('\\\\', '/', realpath(dirname(APPPATH.'vendor/autoload.php'))), '/').'/');\n```\n\nIt is assumed that Composer's vendor/ directory is placed under CodeIgniter's\napplication/ directory. Otherwise correct the setting so VENDORPATH to point correctly.\n\nIf PHPMailer was previously installed through Composer, uninstall it temporarily:\n\n```\ncomposer remove PHPMailer/PHPMailer\n```\n\nNow install this library's package, it will install a correct version of PHPMailer too:\n\n```\ncomposer require ivantcholakov/codeigniter-phpmailer\n```\n\nCreate a file application/helpers/MY_email_helper.php with the following content:\n\n```php\n\u003c?php defined('BASEPATH') OR exit('No direct script access allowed.');\n\n// A place where you can move your custom helper functions,\n// that are to be loaded before the functions below.\n// If it is needed, create the corresponding file, insert\n// your source there and uncomment the following lines.\n//if (is_file(dirname(__FILE__).'/MY_email_helper_0.php')) {\n//    require_once dirname(__FILE__).'/MY_email_helper_0.php';\n//}\n\n// Instead of copying manually or through script in this directory,\n// let us just load here the provided by Composer file.\nif (is_file(VENDORPATH.'ivantcholakov/codeigniter-phpmailer/helpers/MY_email_helper.php')) {\n    require_once VENDORPATH.'ivantcholakov/codeigniter-phpmailer/helpers/MY_email_helper.php';\n}\n\n// A place where you can move your custom helper functions,\n// that are to be loaded after the functions above.\n// If it is needed, create the corresponding file, insert\n// your source there and uncomment the following lines.\n//if (is_file(dirname(__FILE__).'/MY_email_helper_2.php')) {\n//    require_once dirname(__FILE__).'/MY_email_helper_2.php';\n//}\n```\n\nCreate a file application/libraries/MY_Email.php with the following content:\n\n```php\n\u003c?php defined('BASEPATH') OR exit('No direct script access allowed.');\n\n// Instead of copying manually or through script in this directory,\n// let us just load here the provided by Composer file.\nrequire_once VENDORPATH.'ivantcholakov/codeigniter-phpmailer/libraries/MY_Email.php';\n```\n\nThis is an installation that is to be done once. Updating to next versions of\nthis package and PHPMailer would be done later easily:\n\n```\ncomposer update\n```\n\nConfiguration and Sending an E-mail (An Example)\n------------------------------------------------\n\nCreate if necessary or edit the file `application/config/email.php` which contains\nthe default settings for the email engine. For a Gmail account, the setting might be something like this:\n\n```php\n\u003c?php defined('BASEPATH') OR exit('No direct script access allowed.');\n\n$config['useragent']        = 'PHPMailer';              // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'\n$config['protocol']         = 'smtp';                   // 'mail', 'sendmail', or 'smtp'\n$config['mailpath']         = '/usr/sbin/sendmail';\n$config['smtp_host']        = 'smtp.gmail.com';\n$config['smtp_auth']        = true;                     // Whether to use SMTP authentication, boolean TRUE/FALSE. If this option is omited or if it is NULL, then SMTP authentication is used when both $config['smtp_user'] and $config['smtp_pass'] are non-empty strings.\n$config['smtp_user']        = 'yourusername@gmail.com';\n$config['smtp_pass']        = '';                       // Gmail disabled the so-called \"Less Secured Applications\", your Google password is not to be used directly, XOAUTH2 authentication will be used.\n$config['smtp_port']        = 587;\n$config['smtp_timeout']     = 30;                       // (in seconds)\n$config['smtp_crypto']      = 'tls';                    // '' or 'tls' or 'ssl'\n$config['smtp_debug']       = 0;                        // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.\n$config['debug_output']     = '';                       // PHPMailer's SMTP debug output: 'html', 'echo', 'error_log' or user defined function with parameter $str and $level. NULL or '' means 'echo' on CLI, 'html' otherwise.\n$config['smtp_auto_tls']    = false;                    // Whether to enable TLS encryption automatically if a server supports it, even if `smtp_crypto` is not set to 'tls'.\n$config['smtp_conn_options'] = array();                 // SMTP connection options, an array passed to the function stream_context_create() when connecting via SMTP.\n$config['wordwrap']         = true;\n$config['wrapchars']        = 76;\n$config['mailtype']         = 'html';                   // 'text' or 'html'\n$config['charset']          = null;                     // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.\n$config['validate']         = true;\n$config['priority']         = 3;                        // 1, 2, 3, 4, 5; on PHPMailer useragent NULL is a possible option, it means that X-priority header is not set at all, see https://github.com/PHPMailer/PHPMailer/issues/449\n$config['crlf']             = \"\\n\";                     // \"\\r\\n\" or \"\\n\" or \"\\r\"\n$config['newline']          = \"\\n\";                     // \"\\r\\n\" or \"\\n\" or \"\\r\"\n$config['bcc_batch_mode']   = false;\n$config['bcc_batch_size']   = 200;\n$config['encoding']         = '8bit';                   // The body encoding. For CodeIgniter: '8bit' or '7bit'. For PHPMailer: '8bit', '7bit', 'binary', 'base64', or 'quoted-printable'.\n\n// XOAUTH2 mechanism for authentication.\n// See https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2\n$config['oauth_type']          = 'xoauth2_google';      // XOAUTH2 authentication mechanism:\n                                                        // ''                  - disabled;\n                                                        // 'xoauth2'           - custom implementation;\n                                                        // 'xoauth2_google'    - Google provider;\n                                                        // 'xoauth2_yahoo'     - Yahoo provider;\n                                                        // 'xoauth2_microsoft' - Microsoft provider.\n$config['oauth_instance']      = null;                  // Initialized instance of \\PHPMailer\\PHPMailer\\OAuth (OAuthTokenProvider interface) that contains a custom token provider. Needed for 'xoauth2' custom implementation only. \n$config['oauth_user_email']    = '';                    // If this option is an empty string or null, $config['smtp_user'] will be used.\n$config['oauth_client_id']     = '237644427849-g8d0pnkd1jh3idcjdbopvkse2hvj0tdp.apps.googleusercontent.com';\n$config['oauth_client_secret'] = 'mklHhrns6eF-qjwuiLpSB4DL';\n$config['oauth_refresh_token'] = '1/7Jt8_RHX86Pk09VTfQd4O_ZqKbmuV7HpMNz-rqJ4KdQMEudVrK5jSpoR30zcRFq6';\n\n// DKIM Signing\n$config['dkim_domain']      = '';                       // DKIM signing domain name, for exmple 'example.com'.\n$config['dkim_private']     = '';                       // DKIM private key, set as a file path.\n$config['dkim_private_string'] = '';                    // DKIM private key, set directly from a string.\n$config['dkim_selector']    = '';                       // DKIM selector.\n$config['dkim_passphrase']  = '';                       // DKIM passphrase, used if your key is encrypted.\n$config['dkim_identity']    = '';                       // DKIM Identity, usually the email address used as the source of the email.\n```\n\nNotes:\nSet $config['useragent'] as 'PHPMailer' in order PHPMailer engine to be used.\nPHP openssl module should be enabled if encrypted SMTP access is required.\n\nWithin a controller paste the following code for testing purposes:\n\n```php\n$this-\u003eload-\u003elibrary('email');\n\n$subject = 'This is a test';\n$message = '\n    \u003cp\u003eThis message has been sent for testing purposes.\u003c/p\u003e\n\n    \u003c!-- Attaching an image example - an inline logo. --\u003e\n    \u003cp\u003e\u003cimg src=\"cid:logo_src\" /\u003e\u003c/p\u003e\n';\n\n// Get full html:\n$body = '\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"\u003e\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\n\u003chead\u003e\n    \u003cmeta http-equiv=\"Content-Type\" content=\"text/html; charset=' . strtolower(config_item('charset')) . '\" /\u003e\n    \u003ctitle\u003e' . html_escape($subject) . '\u003c/title\u003e\n    \u003cstyle type=\"text/css\"\u003e\n        body {\n            font-family: Arial, Verdana, Helvetica, sans-serif;\n            font-size: 16px;\n        }\n    \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n' . $message . '\n\u003c/body\u003e\n\u003c/html\u003e';\n// Also, for getting full html you may use the following internal method:\n//$body = $this-\u003eemail-\u003efull_html($subject, $message);\n\n// Attaching the logo first.\n$file_logo = FCPATH.'apple-touch-icon-precomposed.png';  // Change the path accordingly.\n// The last additional parameter is set to true in order\n// the image (logo) to appear inline, within the message text:\n$this-\u003eemail-\u003eattach($file_logo, 'inline', null, '', true);\n$cid_logo = $this-\u003eemail-\u003eget_attachment_cid($file_logo);\n$body = str_replace('cid:logo_src', 'cid:'.$cid_logo, $body);\n// End attaching the logo.\n\n$result = $this-\u003eemail\n    -\u003efrom('yourusername@gmail.com')\n    -\u003ereply_to('yoursecondemail@somedomain.com')    // Optional, an account where a human being reads.\n    -\u003eto('therecipient@otherdomain.com')\n    -\u003esubject($subject)\n    -\u003emessage($body)\n    -\u003esend();\n\nvar_dump($result);\necho '\u003cbr /\u003e';\necho $this-\u003eemail-\u003eprint_debugger();\n\nexit;\n```\n\nLoad the corresponding page, executte this code. Check whether an email has been sent. Read the error message,\nif any, and make corrections in your settings.\n\nNote, that most of the SMTP servers require \"from\" address of the message to be the same as the address within\n$config['smtp_user'] setting.\n\nAt the end remove this test.\n\nThe API of this library is the same as the original Email API. Read the CodeIgniter's manual about\n[Email Class](https://www.codeigniter.com/userguide3/libraries/email.html).\n\nFor supporting CodeIgniter 2.x and CodeIgniter 3.0.x a manual installation of an older version of this\nlibrary is needed, see https://github.com/ivantcholakov/codeigniter-phpmailer/tree/1.3-stable\n","funding_links":[],"categories":["Libraries","Email"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivantcholakov%2Fcodeigniter-phpmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivantcholakov%2Fcodeigniter-phpmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivantcholakov%2Fcodeigniter-phpmailer/lists"}