Email Class
The Email class makes sending email simple and easy.
It uses PHP’s built-in mail() function under the hood.
If you are planning to use more advanced features (SMTP, authentication, HTML templates, etc.), you may integrate third-party libraries such as PHPMailer instead.
Basic Usage
Here is a basic example demonstrating how you might send email. Note: This example assumes you are sending the email from one of your controllers.
<?php
$this->call->library('email');
$this->email->sender('your@example.com', 'Your Name');
$this->email->recipient('someone@example.com');
$this->email->subject('Email Test');
$this->email->email_content('Testing the email class.');
$this->email->send();
Available Methods
Method |
Description |
|---|---|
|
$sender_email (required) — Email address of the sender $sender_name (optional) — Name of the sender |
|
$sender_email — Email address where replies should go |
|
$receiver_email (required) — Email address of the recipient |
|
$subject (required) — The subject that will appear in the email |
|
$content (required) — Content of the email
$email_type (optional) — Defaults to |
|
$path (required) — Path where your attachment file is located |
|
Sends the composed email. Must be called last to actually send the email. |
Note
You must call $this->email->send() at the end to actually send the email.
All other methods just prepare the email before sending.