duanduo0520 2014-02-01 08:36
浏览 40
已采纳

通过外部网络发送电子邮件不工作codeigniter

I have a problem when sending email using codeigniter and when i'm printing

$this->email->print_debugger();

it prints:

"Your message has been successfully sent using the following protocol: mail"

but the user can't receive any email after it successfully sends.

here is my code when sending email:

date_default_timezone_set('Asia/Manila');
    $this->load->helper('string');
    $password= random_string('alnum', 8);

    $data = array ('password' => md5($password),
                           'tag' => 0
            );
    $this->db->where('emp_id', $user['employee_id']);
    $this->db->update('credentials', $data);
    $this->load->library('email');
    $this->email->from('noreply@company.com', 'company');
    //$this->email->reply_to('noreply@company.com');
    $this->email->to($user['company_email']);   
    $this->email->subject('Password reset');
    $this->email->message('You have requested a code. Here is your code: '. $password);  
    $check = $this->email->send();

and here is my code when in my config file:

$ci = get_instance();
$ci->load->library('email');
$config['protocol'] = "sendmail";
$config['smtp_host'] = "ssl://mail.company.com";
//$config['smtp_port'] = "465";
$config['smtp_port'] = "25";
//$config['smtp_user'] = "person@company.com"; 
//$config['smtp_pass'] = "";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "
";
$config['crlf'] = "
";

$ci->email->initialize($config);

when we are in the internal network, i can send email successfully. but when i'm at home trying to send email. the code still works but the user can't receive email. thanks in advance guys !

  • 写回答

1条回答 默认 最新

  • dongyan7851 2017-01-03 06:34
    关注

    Try

    $config['protocol'] = "http";
    

    or

    $config['protocol'] = "smtp";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题