Sending email by Mailgun using Codeigniter – onlinecode
In this post we will give you information about Sending email by Mailgun using Codeigniter – onlinecode. Hear we will give you detail about Sending email by Mailgun using Codeigniter – onlinecodeAnd how to use it also give you demo for it if it is necessary.
In this tutorial, We will inform you how to send an email by mailgun using Codeigniter. mailgun is an email tracking tool so we can easily track every email.
We will use mailgun tool to send emails. so first we will set the configuration of setting mailgun in Codeigniter. so you can follow the below steps for the configuration setting.
Step 1: Configuration of EmailFirst, we will create an email.php file in application/config/ directory.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * Mailgun Configuration */ $config['protocol'] = 'smtp'; $config['smtp_host'] = 'smtp.mailgun.org'; $config['smtp_user'] = 'here your user'; $config['smtp_pass'] = 'here your password'; $config['charset'] = 'utf-8'; $config['mailtype'] = 'html'; $config['email']['newline'] = "rn"; ?>
Step 2: Use In ControllerIn this step, we will load the email library in this controller. so we can easily send mail using this mailgun email library.
<?php $this->load->library('email'); $this->email->from('sender@example.com', 'Sender Name'); $this->email->to('recipient@example.com','Recipient Name'); $this->email->subject('Your Subject'); $this->email->message('Your Message'); try { $this->email->send(); echo 'Message has been sent.'; } catch(Exception $e) { echo $e->getMessage(); }
Hope this code and post will helped you for implement Sending email by Mailgun using Codeigniter – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs