0
votes

I have problems when sending email, I make registration and verification by email, when on localhost everything runs smoothly, there are no problems, but when I am hosting, the email function cannot, please help

 $config = array(
        'protocol'  => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' =>  465,
        'smtp_user' => '[email protected]', // change it to yours
        'smtp_pass' => 'mypassword', // change it to yours
        'mailtype'  => 'html',
        'charset'   => 'iso-8859-1',
        'wordwrap'  =>  TRUE
        );
    $message =  "
    <html>
    <head>
    <title>Verifikasi Kode</title>
    </head>
    <body>
    <h2>Terima kasih telah berpartisipasi.</h2>
    <p>Akun anda:</p>
    <p>Email: ".$email."</p>
    <p>Untuk melanjutkan pendaftaran, mohon klik link yang kami berikan</p>
    <h4><a href='".base_url()."register/aktivasi/".$id."'>Activate My Account</a></h4>
    </body>
    </html>
    ";
    $this->email->initialize($config);
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->from($config['smtp_user']);
    $this->email->to($email);
    $this->email->subject('Signup Verification Email, abcd.com | No reply');
    $this->email->message($message);
    if($this->email->send()){
        $this->session->set_flashdata('msg','Kode Aktivasi telah dikirim ke email, mohon di cek');
    }
    else{
        $this->session->set_flashdata('msg', $this->email->print_debugger());
    }

    redirect('register',$data);
}

Error : Failed to authenticate password. Error: 534-5.7.14 Please 534-5.7.14 log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 18sm13749594pfp.100 - gsmtp

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

2
First - try to add $config['smtp_crypto'] = 'ssl';, second - does entered password works with entered login?, third - change smtp_host to smtp.gmail.com - Aksen P
Error : 220 smtp.gmail.com ESMTP 20sm16143786pfp.153 - gsmtp - Tito

2 Answers

0
votes

This issue causes when your access is wrong.

$config = array(
    'protocol'  => 'smtp',
    'smtp_host' => 'smtp.googlemail.com', # Change
    'smtp_port' =>  587, # Change
    'smtp_user' => '[email protected]',
    'smtp_pass' => 'mypassword',
    'smtp_crypto'  => 'tls', # Add
    'mailtype'  => 'html',
    'charset'   => 'utf-8',
    'wordwrap'  =>  TRUE
);

Make sure: Less secure apps enabled in Gmail and Turn off 2-Step Verification is turned off

0
votes

You should change the “Access for less secure apps” to Enabled (it will be disabled, changed to enabled). Try it.