Setting Email Preferences
Lets start with Codeigniter email program configuration.First load the built in email library in controller constructor.
$this->load->library('email');
// Email configuration $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.yourdomainname.com.', 'smtp_port' => 465, 'smtp_user' => 'admin@yourdomainname.com', // change it to yours 'smtp_pass' => '******', // change it to yours 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE );
Refer the complete Codeignitor email sending program. In this program you just need to configure your domain smtp details
load->library('email'); // load the library
}
function index(){
$this->sendEmail();
}
public function sendEmail(){
// Email configuration
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.yourdomainname.com.',
'smtp_port' => 465,
'smtp_user' => 'admin@yourdomainname.com', // change it to yours
'smtp_pass' => '******', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->from('admin@yourdomainname.com', "Admin Team");
$this->email->to("test@domainname.com");
$this->email->cc("testcc@domainname.com");
$this->email->subject("This is test subject line");
$this->email->message("Mail sent test message...");
$data['message'] = "Sorry Unable to send email...";
if($this->email->send()){
$data['message'] = "Mail sent...";
}
// forward to index page
$this->load->view('index', $data);
}
}
?>
Hi I am Yashwant founder of www.technicalkeeda.com, Purpose of this website to share the programming knowledge in the form post , blogs and articles.