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

Tuesday, March 1, 2022

[FIXED] Codeigniter 3 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method

 March 01, 2022     codeigniter, codeigniter-3, php, sendmail     No comments   

Issue

public function send_mail_verification(){
    $this->load->library('email');

    $config = array(
        'protocol'  => 'smtp',
        'smtp_host' => 'smtp.gmail.com',
        'smtp_port' => '587',
        'smtp_crypto' => 'tls',
        'smtp_user' => 'myacc@gmail.com',
        'smtp_pass' => 'mypass',
        'charset'   => 'iso-8859-1'
    );

    $this->email->initialize($config);

    $this->email->from('myemail3@gmail.com', 'Registration');
    $this->email->to('tosomeonemail@gmail.com');

    $this->email->subject('something');
    $this->email->message('Testing email.');

    if($this->email->send()){
        echo "success";
    }
    else{
        show_error($this->email->print_debugger());
    }
}

I've been looking at other solution that I find in the internet and none of them worked for me. I've also tried the mail function and changed some things in sendmail.ini and php.ini in xampp and that worked. However, the send mail configuration in codeigniter-3 is much better if I'm going to share my code to other so that they don't need to change some configuration in their sendmail.ini and php.ini. What do you think causes the error?


Solution

$this->email->set_newline("\r\n");

I added this one and it worked... wonder why.



Answered By - Amben Uchiha
  • 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