【问题标题】:PHP Email sending. Works on http://localhost/ but not on http://{IP ADDRESS}/PHP 电子邮件发送。适用于 http://localhost/ 但不适用于 http://{IP ADDRESS}/
【发布时间】:2015-06-13 07:35:12
【问题描述】:

我正在使用此代码从本地主机发送电子邮件。它在 codeIgniter 中。我的操作系统是 Ubuntu 14.XX

function email()
    {
        $config = array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => '*****@gmail.com', // change it to yours
        'smtp_pass' => '*****', // change it to yours
        'mailtype' => 'html',
        'charset' => 'UTF-8',
        );

        $message = 'aggasdgsd';
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        $this->email->from('*****@gmail.com'); // change it to yours
        $this->email->to('****@gmail.com');// change it to yours
        $this->email->subject('Rdfgsdfgf ing');
        $this->email->message($message);
        if($this->email->send())
       {
        echo 'Email sent.';
       }
       else
      {
       show_error($this->email->print_debugger());
      }
    }

当我使用 URL http://localhost/ci_project/email BUT 时,电子邮件被发送 如果我使用 URL http://10.10.10.XX/ci_project/email 则不起作用,也没有错误消息。

有什么想法,为什么在 URL 中使用 localhost 时它可以工作,而当我在 URL 中使用 IP 地址时它不工作??

【问题讨论】:

  • 是的,它是本地的。我正在本地主机上工作。
  • 如果你echo 什么东西,那行得通吗? /var/log/apache2/error.log 中的任何内容?可能是 apache 配置问题

标签: php apache codeigniter


【解决方案1】:

检查服务器上是否有电子邮件服务器在工作。如果您使用的是 sendmail,请在服务器上尝试此命令 服务 sendmail 重启

【讨论】:

    【解决方案2】:

    您的 PHP 配置是否启用了 ssl? 检查您的 php.ini 中是否有以下行

    extension=php_openssl.dll
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      • 1970-01-01
      • 2011-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多