【问题标题】:overcome error messages from appearing when failing because of slow internet in CodeIgniter克服由于 CodeIgniter 中的互联网速度慢而失败时出现的错误消息
【发布时间】:2016-02-17 22:42:36
【问题描述】:

克服由于CodeIgniter中网速慢而失败时出现的错误消息,

如果电子邮件由于互联网超时而无法发送,则显示消息或重定向,以便没有错误消息。谢谢

function sent_email_contact_admin($data){
    $CI=& get_instance();
    $config['protocol'] = 'smtp';
    $config['smtp_host'] = 'ssl://smtp.googlemail.com';
    $config['smtp_port'] = 465;
    $config['smtp_user'] = 'rental.alternet@gmail.com';
    $config['smtp_pass'] = '******';
    $config['mailtype'] = 'html';
    $config['charset'] = 'iso-8859-1';
    $config['wordwrap'] = TRUE;
    $data = array (
        'nama' => $data['nama'],
        'email' => $data['email'],
            'message' => $data['message']

    );

    $data['base_url'] = base_url();
    $message = $CI->load->view('layout/email_template_contact_admin', $data, true); 
    $CI->load->library('email', $config);
    $CI->email->set_newline("\r\n");
    $CI->email->from('rental.alternet@gmail.com');
    $CI->email->to('rental.alternet@gmail.com');
    $CI->email->reply_to($data['email']);
    $CI->email->subject("Info Contact Alternet");
    $CI->email->message($message);

    $CI->email->send();



}

【问题讨论】:

  • 也许包装在 try catch 中?

标签: php codeigniter email connection-timeout


【解决方案1】:

试试这个

  if ( ! $CI->email->send())
    {
            // Generate error
    }
  else
   {
        //redirect
   }

【讨论】:

  • 请编辑您的帖子并解释为什么会这样。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-31
  • 1970-01-01
相关资源
最近更新 更多