Send email in codeigniter and hostinger


hostinger is a free popular hosting site .www.hostinger.in

hostinger povider you free 2 database space , 2 email accounts So you can create a email account first
then you can use this php function and configerration to send emails.

    function send_Email( $receiver_email, $subject, $message )
    {




// Storing submitted values
$sender_email = 'your email';
$user_password = 'password';

$username = 'your username';


// Configure email library
$config['protocol'] = 'http';
$config['smtp_host'] = 'mx1.hostinger.in';
$config['smtp_timeout'] = '7';
$config['smtp_port'] = 110;
$config['charset']    = 'utf-8';
        $config['newline']    = "\r\n";
        $config['mailtype'] = 'text'; // or html
        //$config['validation'] = TRUE; // bool whether to validate email or not
$config['smtp_user'] = $sender_email;
$config['smtp_pass'] = $user_password;

// Load email library and passing configured values to email library
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Sender email address
$this->email->from($sender_email, $username);
// Receiver email address
$this->email->to($receiver_email);
// Subject of email
$this->email->subject($subject);
// Message in email
$this->email->message($message);

if ($this->email->send()) {
return 'Email Successfully Send !';
} else {
return 'Email Servers are Currently Unavilable..';
}
    }




Comments

Post a Comment

Popular Posts