【问题标题】:sending email through external network not working codeigniter通过外部网络发送电子邮件不起作用codeigniter
【发布时间】:2014-02-01 08:36:57
【问题描述】:

我在使用 codeigniter 发送电子邮件和打印时遇到问题

$this->email->print_debugger();

打印出来:

"您的消息已使用以下协议成功发送: 邮件”

但用户发送成功后收不到任何邮件。

这是我发送电子邮件时的代码:

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();

这是我在配置文件中的代码:

$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'] = "\r\n";
$config['crlf'] = "\r\n";

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

当我们在内部网络中时,我可以成功发送电子邮件。但是当我在家尝试发送电子邮件时。该代码仍然有效,但用户无法接收电子邮件。在此先感谢各位!

【问题讨论】:

  • 您在家使用同一台计算机进行测试吗?有时邮件服务配置不正确,不会发送任何电子邮件。还要检查关闭的端口。您可以尝试直接使用telnet连接,检查是否可以连接
  • 是的,我在发送电子邮件时使用同一台计算机。什么是远程登录?对不起
  • $config['smtp_user'] = "";// 使用你的真实邮箱ID,$config['smtp_pass'] = ""; // 使用与您相同的密码
  • Smtp 端口 25 可能被您的 ISP 阻止。尝试将其更改为 587,或者使用 ssl smtp 端口 465。
  • 我认为这应该可以帮助你......phpecosystem.com/2014/01/…

标签: php codeigniter email sendmail


【解决方案1】:

试试

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

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

【讨论】:

    猜你喜欢
    • 2017-10-21
    • 1970-01-01
    • 2014-03-03
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    • 2018-09-21
    • 2017-11-30
    • 1970-01-01
    相关资源
    最近更新 更多