mediatemple - 无法使用codeigniter发送电子邮件 [英] mediatemple - can't send email using codeigniter

查看:336
本文介绍了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.

这是错误: / p>

This is the error:

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


b $ b

这是我的代码:
我用正确的smtp替换了sxxxxx.gridserver.com。

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("\r\n");

        $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("\r\n");

        $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'] = "\r\n";
        $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发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆