Problem when trying to send email with Codeigniter

0

Error

PHP Error was encountered

Severity: Notice

Message: Use of undefined constant INTL_IDNA_VARIANT_UTS46 - assumed 'INTL_IDNA_VARIANT_UTS46'

Filename: libraries/Email.php

My file

        $this->load->library('email');
        $this->email->to('[email protected]');
        $this->email->from('[email protected]','xxxxx');
        $this->email->subject('Test Email (TEXT)');
        $this->email->message('Text email testing by CodeIgniter Email library.');
        $this->email->send();

Does anyone know what the problem is? The error points to this line:

$this->email->send();

The message arrives correctly, the problem is because it marks me that?

    
asked by DoubleM 27.03.2018 в 22:39
source

1 answer

0

Well what could be missing would be the configuration of the email:

Example:

 function sendEmail(){

     $this->load->library('email');
     $config['protocol']    = 'smtp';
     $config['smtp_host']    = 'ssl://smtp.gmail.com';
     $config['smtp_port']    = '465';
     $config['smtp_timeout'] = '7';
     $config['smtp_user']    = '[email protected]';
     $config['smtp_pass']    = 'contraseñagmail';
     $config['charset']    = 'utf-8';
     $config['newline']    = "\r\n";
     $config['mailtype'] = 'text'; // o html
     $config['validation'] = TRUE; // para validar el correo electronico 

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

     $this->email->from('[email protected]', 'myname');
     $this->email->to('[email protected]'); 

     $this->email->subject('Email Test');
     $this->email->message('Testing the email class.');  

     $this->email->send();

    }

Important note the configurations can also be placed in an external file email.php in ./application/config/.

Example:

<?php
    $config['protocol']    = 'smtp';
    $config['smtp_host']    = 'ssl://smtp.gmail.com';
    $config['smtp_port']    = '465';
    $config['smtp_timeout'] = '7';
    $config['smtp_user']    = '[email protected]';
    $config['smtp_pass']    = 'contraseñagmail';
    $config['charset']    = 'utf-8';
    $config['newline']    = "\r\n";
    $config['mailtype'] = 'text'; // o html
    $config['validation'] = TRUE; // para validar el correo electronico 
>

Always substitute gmail username and password for the real ones of you ...

    
answered by 11.04.2018 в 15:31