PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, March 14, 2022

[FIXED] Codeigniter email send but not received

 March 14, 2022     codeigniter, codeigniter-3     No comments   

Issue

I am using CodeIgniter to send emails it showing me success message "Your Email Send is Successful" but I am not receiving email on my account.Is it a server problem, I am stuck with this problem for many days.

        $name       = post('name');
        $from_email = post('from_email');
        $to         = post('to');
        $subject    = post('subject');
        $msg        = post('msg');


        $this->load->library('email');

        $this->email->from($from_email, $name);
        $this->email->to($to);

        $this->email->subject($subject);
        $this->email->message($msg);

        $result = $this->email->send();

        if ($result) 
        {
            $msg = "Your Email Send is Successfully";
            $this->session->set_flashdata('success',$msg);
            redirect('users','refresh');
        }
        else
        {
            $msg = "Error! Can not Send Email";
            $this->session->set_flashdata('error', $msg);
            redirect('users','refresh');
        }

Solution

You can try this:

public function send_mail(){
    $this->load->library('email');
    $to_email = 'abc@gmail.com';
    $from_email = 'xyz@gmail.com';
    
    $config = array(
                    'charset' => 'utf-8',
                    'wordwrap' => TRUE,
                    'mailtype' => 'html'
                );
    
    $this->email->initialize($config);
    
     $this->email->from($from_email);
                $this->email->to($to_email);
                $this->email->subject('Test mail send');
                $this->email->message('Test Mail');
    
        if($this->email->send()){
            echo "send";
        }else{
            echo "error";
        }
}


Answered By - Shabbirhasan Nandoliya
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing