Download the PHP package adrianorsouza/codeigniter-phpmailer without Composer
On this page you can find all versions of the php package adrianorsouza/codeigniter-phpmailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adrianorsouza/codeigniter-phpmailer
More information about adrianorsouza/codeigniter-phpmailer
Files in adrianorsouza/codeigniter-phpmailer
Package codeigniter-phpmailer
Short Description CodeIgniter Mail Plugin Powered by PHPMailer Library
License MIT
Homepage https://github.com/adrianorsouza/codeigniter-phpmailer
Informations about the package codeigniter-phpmailer
Codeigniter mail plugin powered by PHPMailer
A simple CodeIgniter mail class to connect your application through the powerful PHPMailer library.
Tested over CodeIgniter v2.1.4 / v3.0-dev and PHPMailer Version 5.2.7
Install via Composer
To get this plugin via composer is the quick start.
This plugin utilizes Composer for its installation and PHPMailer dependency. If you haven't already, start by installing Composer.
And are available via Composer/Packagist. Once you have Composer configured in your environment run the command line:
This command will write into composer.json beyond download and place this project files and PHPMailer dependencies into your vendor
folder.
If you have not included the composer autoload you must do it at the very top of your index.php page or whatever you are running this plugin.
that's all. Your able to send e-mail anywhere inside your CodeIgniter application.
To create an instance of Mail()
class:
Alternatively manual installation
If you don't speak Composer, follow this instructions:
-
Download this zip files and uncompress it within of your
application/
directory. - Download PHPMailer files dependencies because is not include in this package.
- PHPMailerAutoload.php
- class.smtp.php
- class.phpmailer.php
place them into your third_party
folder or what/you/want
as long as you include PHPMailer autoloader where you call the class Mail()
.
To load class Mail()
use the same Codeigniter super-object:
That's all.
Configuration
After get this plugin you have to setup mail_config.php
file that contains all mail server configuration that must be placed in your application/config/
folder.
In order to be able to send emails from your local development either production server you must provide a valid SMTP account authentication.
So in this config file, you setup your smtp server and password, login, mail from and etc...
To set up a Gmail smtp account to send your emails, you must set the config mail_smtp_secure
to TLS
.
To send any message with a HTML template file place it into your views folder. The default folder is views/templates/email
if you want to change it, set this in mail_config.php
as long as it remains under views folder.
Sample mail_config.php
Usage
Send a basic email message using a string as HTML body.
Send email message as an external HTML template
Send email message as an associative array with external HTML template
Create a HTML template file and name it as sample-2.html
.
Then set up a new mail message.
More examples you can find in file Sample_controller.php
at application/controllers
folder
This class is capable to send email message by passing an array as body content, external template HTML/TEXT file or as string.
If you don't pass an email address as a parameter $to
to sendMail($Subject, $to);
methods by default $to
will be defined with your config mail_replyto_mail
value.
You can pass any config from the mail_config.php
into class constructor as an array of values:
this will enable BCC e send a copy as BCC to address [email protected]
Notes
-
If you are not in Composer instead of create new instance class ie:
$mail = new Mail();
just load class normally with:$this->load->library('mail');
and use the super object$this->mail->sendMail();
instead. -
By default the PHPMailer sends email messages in HTML format and an alternative Plain-Text for those Mail Clients that do not support HTML. But the plain-text content is by default extract from your HTML body and stripped to a text. Sometimes depending on your HTML structure the format of your plain text can be unreadable, So if you want to have a specific template for text-plain format just create a .txt file of your HTML template as the same name ending with .txt extension write it only text with your needs and the Mail plugin will find it and use its contents.
- Fell free to custom this plugin with your needs.
Bugs
Have you found a bug? Please open a new issue.
Author
Adriano Rosa
Further reading about PHPMailer
https://github.com/Synchro/PHPMailer