dsjk3214 2016-01-18 04:43
浏览 54
已采纳

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

I wrote an function to send an email to the user using the email they put on their registration form. However while testing it the email does not go to the email address entered. I checked to make sure that the function was working by having the email cc to an address, which worked. Below is the function.

View

    <div class="col-lg-4 col-lg-offset-4">
    <h2>Hello There</h2>
    <h5>Please enter the required information below.</h5>     
<?php 
    $fattr = array('class' => 'form-signin');
    echo form_open('/main/register', $fattr); ?>
    <div class="form-group">
      <?php echo form_input(array('name'=>'firstname', 'id'=> 'firstname', 'placeholder'=>'First Name', 'class'=>'form-control', 'value' => set_value('firstname'))); ?>
      <?php echo form_error('firstname');?>
    </div>
    <div class="form-group">
      <?php echo form_input(array('name'=>'lastname', 'id'=> 'lastname', 'placeholder'=>'Last Name', 'class'=>'form-control', 'value'=> set_value('lastname'))); ?>
      <?php echo form_error('lastname');?>
    </div>
    <div class="form-group">
      <?php echo form_input(array('name'=>'email', 'id'=> 'email', 'placeholder'=>'Email', 'class'=>'form-control', 'value'=> set_value('email'))); ?>
      <?php echo form_error('email');?>
    </div>
    <?php echo form_submit(array('value'=>'Sign up', 'class'=>'btn btn-lg btn-primary btn-block')); ?>
    <?php echo form_close(); ?>
</div>

Controller

 public function register()
    {

        $this->form_validation->set_rules('firstname', 'First Name', 'required');
        $this->form_validation->set_rules('lastname', 'Last Name', 'required');    
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');    

        if ($this->form_validation->run() == FALSE) {   
            $this->load->view('header');
            $this->load->view('register');
            $this->load->view('footer');
        }else{                
            if($this->user_model->isDuplicate($this->input->post('email'))){
                $this->session->set_flashdata('flash_message', 'User email already exists');
                redirect(site_url().'main/login');
            }else{

                $clean = $this->security->xss_clean($this->input->post(NULL, TRUE));
                $id = $this->user_model->insertUser($clean); 
                $token = $this->user_model->insertToken($id);                                        

                $qstring = base64_encode($token);                    
                $url = site_url() . 'main/complete/token/' . $qstring;
                $link = '<a href="' . $url . '">' . $url . '</a>'; 


                $message = '';                     
                $message .= '<strong>You have signed up with our website</strong><br>';
                $message .= '<strong>Please click:</strong> ' . $link;                          

                $config = array(
                    'protocol' => 'smtp',
                    'smtp_host' => 'host',
                    'smtp_port' => 'port',
                    'smtp_user' => 'username',
                    'smtp_pass' => 'password');

                $this->load->library('email', $config);

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

                $this->email->from('***@****.com', 'High Ball Run8');
                $this->email->to(set_value("email"));
                $this->email->cc('****@*****.com');

                $this->email->subject('Highball Registration Email Activation');
                $this->email->message($message);
                if ($this->email->send()) {
                       redirect(site_url());
                   }else{
                    show_error($this->email->print_debugger());
                   }
                exit;
  • 写回答

2条回答 默认 最新

  • doudao1950 2016-01-18 05:27
    关注

    Have you tried

    var_dump(set_value("email")); exit();
    

    To see what the output is? Chances are you are not getting the to address correctly, if the hardcoded CC works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上