doufei2662
2018-04-05 14:47
浏览 60
已采纳

电子邮件不发送代码点火器

I'm having a big problem with code igniter emails. When i'm working localhost the email is normaly send by smtp protocol, but when i up to the server the mail sending is not working.

My mail configurations :

$config['protocol'] = 'mail';
        $config['smtp_host'] = 'mail.duplov.com.br';
        $config['smtp_port'] = '587';
        $config['smtp_timeout'] = '30';
        $config['smtp_user']= '**********';
        $config['smtp_pass'] = '***********';
        $config['charset'] = 'utf-8';
        $config['newline'] = '
';
        $config['mailtype'] = 'html';

Detail tha stmp_pass and stmtp_user i just hide. My send email code :

public function validacao(){
        $this->load->library('form_validation');
        $this->form_validation->set_rules('nome','Nome','required|min_length[5]');
        $this->form_validation->set_rules('email','Email','required|valid_email');
        $this->form_validation->set_rules('telefone','Telefone','required|min_length[13]',array('min_length' => 'Você precisa colocar um telefone válido incluindo o DDD'));
        $this->form_validation->set_rules('mensagem','Mensagem','required|min_length[20]');

        if($this->form_validation->run() == FALSE){
            $erros = array('mensagens' => validation_errors());
            $jsonStr = json_encode($erros);
            echo $jsonStr;
        }
        else{
            if($mensagem = $this->enviar_mensagem($this->input->post('nome'),$this->input->post('email'),$this->input->post('telefone'),$this->input->post('mensagem'))){
                $sucesso['mensagens']   = 'sucesso';
                $jsonStr = json_encode($sucesso);
                echo $jsonStr;
            }else{
                $sucesso['mensagens']   = $this->email->print_debugger();
                $jsonStr = json_encode($sucesso);
                echo $jsonStr;
            }
        }
    }

    public function enviar_mensagem($nome,$email,$telefone,$mensagem){
        $this->load->model('funcoes');
        $this->funcoes ->contato($nome,$email,$telefone,$mensagem);
        $emails = $this->funcoes->get_infos();
        foreach ($emails as $em){
            $this->load->library('email');
            $dados['nome'] = $nome;
            $dados['email'] = $email;
            $dados['telefone'] = $telefone;
            $dados['mensagem'] = $mensagem;
            $mensagem = $this->load->view('email/template',$dados,true);
            $this->email->from("no-reply@duplov.com.br","Gerenciador do website");
            $this->email->to($em->email);
            $this->email->subject('Contato site');
            $this->email->message($mensagem);
            return $this->email->send();
        }

The error i'm getting :

220-a1-caju27.servidorwebfacil.com ESMTP Exim 4.89_1 #1 Thu, 05 Apr 2018 11:44:31 -0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. 
hello: 250-a1-caju27.servidorwebfacil.com Hello oestedeminas.cphost0027.servidorwebfacil.com [200.98.245.32]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-CHUNKING
250-STARTTLS
250 HELP
Failed to authenticate password. Error: 535 Incorrect authentication data
It is not possible to send e-mail using PHP SMTP. Your server may not be configured to send mail using this method.
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujiao9866 2018-04-06 07:35
    已采纳

    It looks like you are using $config['protocol'] = 'mail';

    Are you using the right protocol? Try changing to $config['protocol'] = 'smtp'; Make sure you enter the right smtp details and the outgoing port isn't blocked on your server too. Try another smtp server or test it again locally using MailSlurper, just to confirm.

    You can read more on email preferences here.

    打赏 评论

相关推荐 更多相似问题