0
votes

I am trying send email using codeigniter function. I have try this code.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


public function __construct()
{
     parent::__construct();


}
 function index()
{
    $this->load->library('email');

    $this->email->from('[email protected]', 'Your Name');
    $this->email->to('[email protected]');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');

    $this->email->send();
    //$this->load->view('welcome_message');
}

} ?>


I got this error.

A PHP Error was encountered

Severity: Warning

Message: mail(): Failed to connect to mailserver at "smtp.wlink.com.np" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Filename: libraries/Email.php

Line Number: 1553

1
is it hosted in godaddy?? - Niranjan N Raju
The error message is pretty precise. So what is the question? - arkascha
A simple DNS lookup reveals that the MX records for that hostname point to mx-03.wlink.com.np or mx-04.wlink.com.np. So you probably want to use those in your settings instead. - arkascha
Where is your controller class? - Mr. ED

1 Answers

1
votes

The error message helps a little to know what happens. You can contact your supplier to provide you information on the SMTP server or set your preferences mail CodeIgniter to not use SMTP they use the native PHP mail function https://codeigniter.com/user_guide/libraries/email.html#email-preferences

You could also use the Gmail SMTP http://www.formget.com/codeigniter-gmail-smtp/