mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
问题描述
我无法在 codeigniter 中使用 mediatemple 发送电子邮件.我检查了电子邮件密码和 smtp 主机,它们是正确的.
I can't send emails using mediatemple in codeigniter.I've checked the email password and smtp host and they are correct.
这是错误:
Severity: Notice
Message: fwrite() [function.fwrite]: send of 12 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host.
Filename: libraries/Email.php
Line Number: 1846
这是我的代码:我已将 sxxxxx.gridserver.com 替换为正确的 smtp.
This is my code: I have replaced sxxxxx.gridserver.com with my correct smtp.
function _sendEmail($from,$fromname,$to,$subject,$message){
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'sxxxxx.gridserver.com',
'smtp_port' => 465,
'smtp_user' => 'noreply@mywebsite.com',
'smtp_pass' => 'mypass'
);
$this->load->library('email',$config);
$this->email->set_newline("
");
$this->email->from($from,$fromname);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
}
任何帮助将不胜感激.
我已经使用端口 25 解决了这个问题.
推荐答案
你需要初始化配置,见 电子邮件类的 codeigniter 文档.
You need to initialise the the config, see the codeigniter documentation for the email class.
这是我的例子,效果很好......
Here is my example which works well...
function send_email($attributes) {
$this->load->library('email');
$this->email->set_newline("
");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'host';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'user@smtp.com';
$config['smtp_from_name'] = 'FROM NAME';
$config['smtp_pass'] = 'XXX';
$config['wordwrap'] = TRUE;
$config['newline'] = "
";
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from($config['smtp_user'], $config['smtp_from_name']);
$this->email->to($attributes['to']);
$this->email->cc($attributes['cc']);
$this->email->bcc($attributes['cc']);
$this->email->subject($attributes['subject']);
$this->email->message($attributes['message']);
if($this->email->send()) {
return true;
} else {
return false;
}
}
这篇关于mediatemple - 无法使用 codeigniter 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mediatemple - 无法使用 codeigniter 发送电子邮件
基础教程推荐
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01