Email codeigniter SMTP error was encountered: 450 4.7.1

Can you explain to me how I send email from a form by locaweb servers, I have a site of a client hosted on locaweb, but the sending form does not work using their email, I would like to know if anyone has had a similar problem on locaweb using codeigniter and how you solved it.

 if ( ! defined('BASEPATH')) exit('No direct script access allowed');


 $config['protocol']='smtp';
 $config['smtp_host']='smtp.xxx.xxx';
 $config['smtp_port']='587';
 $config['smtp_timeout']='60';
 $config['smtp_user']='xxxxx';
 $config['smtp_pass']='xxxxx';
 $config['charset']='utf-8';
 $config['newline']="\r\n";
 $config['mailtype']="html";
 $config['smtp_crypto'] = 'tls';



    $nome= $this->input->post('nome', TRUE);        
    $empresa = $this->input->post('nome-empresa', TRUE);    
    $telefone = $this->input->post('telefone', TRUE);      
    $celular = $this->input->post('celular', TRUE);
    $email = $this->input->post('email', TRUE);
    $cidade = $this->input->post('cidade', TRUE);
    $bairro = $this->input->post('bairro', TRUE);
    $endereco = $this->input->post('endereco', TRUE);

            $data['email'] = [
                'nome' =>$nome,
                'empresa' =>$empresa,
                'telefone' =>$telefone,
                'celular'  =>$celular,
                'cidade' => $cidade,
                'bairro' => $bairro,
                'endereco' => $endereco,
                'email' => $email    

            ];

            $mensagem = $this->load->view('template_email/index', $data, true);
            $this->email->from($email);  
            $this->email->to('email'); 
            $this->email->subject('Solicitação de Visita');        
            $this->email->message($mensagem);                   
            $this->email->send();     
            echo $this->email->print_debugger();

In localhost sends normal with other smtp servers, the settings are in config / email.php and work, less on locaweb, how do anyone know?

The Error returned is this:

The following SMTP error was encountered: 450 4.7.1: Recipient address rejected: Access Denied Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method

Author: rray, 2016-03-09

2 answers

I managed to solve the problem, in reality locaweb has an anti-span system, when you send an email with html template, you can not leave the field of those who send with the email registered by the sender, in reality, the form must be sent by an email from your domain, follow the code with the solution below, take into account that I am using codeigniter, the email library is being loaded by autoload, and the email configuration files are in a place email file.php inside the config, which ensures that the configuration is already loaded,

  //configuração

  $config['protocol']='smtp';
  $config['smtp_host']='smtp.seudominio.com.br';
  $config['smtp_port']='587';
  $config['smtp_timeout']='60';
  $config['smtp_user']='[email protected]';
  $config['smtp_pass']='xxxxx';
  $config['charset']='utf-8';
  $config['newline']="\r\n";
  $config['mailtype']="html";
  $config['smtp_crypto'] = 'tls';


//controller
$nome= $this->input->post('nome', TRUE);        
$empresa = $this->input->post('nome-empresa', TRUE);    
$telefone = $this->input->post('telefone', TRUE);      
$celular = $this->input->post('celular', TRUE);
$email = $this->input->post('email', TRUE);
$cidade = $this->input->post('cidade', TRUE);
$bairro = $this->input->post('bairro', TRUE);
$endereco = $this->input->post('endereco', TRUE);

        $data['email'] = [
            'nome' =>$nome,
            'empresa' =>$empresa,
            'telefone' =>$telefone,
            'celular'  =>$celular,
            'cidade' => $cidade,
            'bairro' => $bairro,
            'endereco' => $endereco,
            'email' => $email    

        ];


        $mensagem = $this->load->view('template_email/index', $data, true);
        $this->email->from('[email protected]');  
        $this->email->to('[email protected]'); 
        $this->email->reply_to($email); //email de resposta
        $this->email->subject('Solicitação de Visita');        
        $this->email->message($mensagem);                   
        $this->email->send();     
        echo $this->email->print_debugger();
 2
Author: Aminadabe Silva, 2016-03-10 16:05:15

I think we missed starting the lib with the settings.

$config['protocol']='smtp';
 $config['smtp_host']='smtp.xxx.xxx';
 $config['smtp_port']='587';
 $config['smtp_timeout']='60';
 $config['smtp_user']='xxxxx';
 $config['smtp_pass']='xxxxx';
 $config['charset']='utf-8';
 $config['newline']="\r\n";
 $config['mailtype']="html";
 $config['smtp_crypto'] = 'tls';
 $this->load->library('email', $config);
 0
Author: rpereira15, 2016-03-09 19:33:56