【发布时间】: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