Send Email in CodeIgniter 4 with HTML Template

We will follow 3 simple step

  • SMTP Setting in CodeIgniter 4
  • Load Email service/library in CodeIgniter 4
  • Send mail in CodeIgniter 4

Here we can use Custom HTML Template and Attachment in CodeIgniter 4.

STEP 1: SMTP Setting

Open /app/Config/Email.php and set values. Example given below which i used.

 

STEP 2 : Load Email service/library

You can load in __construct or in your Controller method, but here i will load in __construct, because we will need this in whole controller. find example below.

 

STEP 3 : Complete code of Controller Method

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *