【发布时间】:2019-06-27 07:17:40
【问题描述】:
public function send_mail()
{
$this->CI->load->library('email');
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtpauth.net4india.com',
'smtp_port' => 587,
'smtp_user' => 'xxxxx@my_domain.in',
'smtp_pass' => 'xxxxxxxx',
'newline' => '\r\n',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->CI->email->initialize($config);
$this->CI->email->set_mailtype("html");
$this->CI->email->set_newline("\r\n");
$this->CI->email->from('info@my_domain.in', 'My Domain');
$this->CI->email->to('xxxx@gmail.com');
$this->CI->email->subject("Test Subject");
$this->CI->email->message('Test Content');
if(!$this->CI->email->send())
{
$error = $this->CI->email->print_debugger();
echo "<pre>"; print_r($error); echo "</pre>"; exit;
return false;
}
return true;
}
我在 net4india.com 上注册了我的域和电子邮件,并在 godaddy 托管。
使用上面的代码,我可以从本地主机发送邮件,但不能从 Godaddy 服务器发送邮件。
我在 godaddy 托管中添加了 mx 记录。 将路由更改为远程管理器。
我做了很多谷歌搜索仍然没有解决方案。
【问题讨论】:
-
你试过 465 端口了吗
-
是的,我试过了,但效果不错
-
尝试添加ssl到服务器:
'smtp_host' => 'ssl://smtpauth.net4india.com',
标签: php codeigniter smtp