dswqz24846 2015-08-23 10:48
浏览 34

Codeigniter电子邮件未发送[重复]

This question already has an answer here:

I have a Codeigniter form like the following:

CI form

When I click on the green check sign for "Approve" or the red cross sign for "Reject" , an email is supposed to be sent to certain addresses. But I've checked that the mail was never sent.

For better understanding, here are some of my codes:

View:

<td class="center">
                <?php
                $edit_text = (ACTION_BUTTON_TEXT_SHOW) ? 'Approve' : '&nbsp;';
                echo anchor('staff_requisitions/update_approve/' . $row['id'],"<img src='".base_url()."/media/images/accept.png'>", $edit_text, array('class' => 'edit_button', 'title' => 'Approve'));
                ?>
</td>
<td class="center">
                <?php
                $edit_text = (ACTION_BUTTON_TEXT_SHOW) ? 'Reject' : '&nbsp;';
                echo anchor('staff_requisitions/update_reject/' . $row['id'],"<img src='".base_url()."/media/images/reject.png'>", $edit_text, array('class' => 'edit_button', 'title' => 'Reject'));
                ?>
</td>

Controller:

function __construct()
{
    parent::__construct();
    $this->load->database();
    $this->load->model('Staff_requisition');
    $this->load->helper('url');
    $this->load->helper('html');
    $this->load->helper('form');
    $this->load->library('email');
    $this->output->enable_profiler(false);
}

function update_approve(){
    $id = $this->uri->segment(3);
    $this->Staff_requisition->update_approve($id);
    //$data['list_of_emails'] = $this->Staff_requisition->get_list_of_emails($id);
    $this->email->from('joshamee_gibbs@example.com', 'Joshamee');
    $this->email->to('capn_jack_sparrow@example.com');
    $this->email->cc('william.turner1724@example.com');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class. Your requisition approved.');
    $this->email->send();
    echo $this->email->print_debugger();
    $this->session->set_flashdata('message', 'The requisition request has been approved');
    redirect('staff_requisitions/index');
}

function update_reject(){
    $id = $this->uri->segment(3);
    $this->Staff_requisition->update_reject($id);
    //$data['list_of_emails'] = $this->Staff_requisition->get_list_of_emails($id);
    $this->email->from('joshamee_gibbs@example.com', 'Joshamee');
    $this->email->to('capn_jack_sparrow@example.com');
    $this->email->cc('william.turner1724@example.com');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class. Your requisition rejected.');
    $this->email->send();
    echo $this->email->print_debugger();
    $this->session->set_flashdata('message', 'Sorry, the requisition request has been rejected');
    redirect('staff_requisitions/index');
}

Model:

function __construct()
{
    parent::__construct();
}

function update_approve($rid){
        $this->db->query("UPDATE `staff_requisitions` SET `is_approve` = 1 WHERE `id` = $rid ");
}

function update_reject($rid){
    $this->db->query("UPDATE `staff_requisitions` SET `is_approve` = 0 WHERE `id` = $rid ");
}

function get_list_of_emails($id){
    $q = $this->db->query("SELECT * FROM `requisition_emails` WHERE `req_id` = $id")->result_array();
    return $q;
}

What am I missing/doing wrong?

N.b. I'm running this application in localhost.

</div>
  • 写回答

1条回答 默认 最新

  • dpd3982 2015-08-23 11:11
    关注

    Use this setting

    public $smtp = array(
      'transport' => 'Smtp',
      'from' => 'your_mail@gmail.com',
      'host' => 'ssl://smtp.gmail.com',
      'port' => 465,
      'timeout' => 30,
      'username' => 'your_mail@gmail.com',
      'password' => '*****'
    )
    
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢