Codeigniter电子邮件发送问题

时间:2016-04-19 20:38:22

标签: php codeigniter ssl

这是链接:http://theartvalley.com/clients/theartvalley.com/

我在电子邮件发送代码中使用它:

<?php
include_once (dirname(__FILE__) . "/load_pages.php");
class Generalfunctions extends Load_pages
{
    function __construct()
    {
        parent::__construct();

    }
function send_mail(){

$smtp_host = "uscentral48.myserverhosts.com";
$smtp_port = 465;
$smtp_user = "admin@theartvalley.com";
$smtp_pass = "sender33";
$send_email = "gnkafridi@gmail.com";

$config = Array(
          "protocol" => "smtp",
          "smtp_host" => $smtp_host,
          "smtp_port" => $smtp_port,
          "smtp_user" => $smtp_user, 
          "smtp_pass" => $smtp_pass,
          "smtp_crypto" => "ssl",
          "mailtype" => "html",
          "charset" => "iso-8859-1",
          "wordwrap" => TRUE,
          "wordwrap" => "\r\n" //use double quotes to comply with RFC 822
        );

                $name = $this->input->post("name");
                $email = $this->input->post("email"); 
        $subj = $this->input->post("subj");
        $msg = $this->input->post("msg");

      $this->load->library("email", $config);
      $this->email->from($email, $name); 
      $this->email->to($send_email);  
      $this->email->subject($subj);
      $this->email->message($msg);

      if($this->email->send()){ echo "Your message has successfully send to appropriate email ($send_email)"; }
      else{ echo "Server has busy, please send email manually into $send_email"; }
}
}

这显示了错误:

A PHP Error was encountered
Severity: Warning

Message: fgets() [function.fgets]: SSL: Connection reset by peer

Filename: libraries/Email.php

Line Number: 1870

A PHP Error was encountered
Severity: Warning

Message: fwrite() [function.fwrite]: SSL: Broken pipe

Filename: libraries/Email.php

Line Number: 1847

A PHP Error was encountered
Severity: Warning

Message: fwrite() [function.fwrite]: SSL operation failed with code 1. OpenSSL Error messages: error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry

Filename: libraries/Email.php

Line Number: 1847

1 个答案:

答案 0 :(得分:0)

我不明白为什么你需要另一个库并扩展它。

$config = Array(
          "protocol" => "smtp",
          "smtp_host" => $smtp_host,
          "smtp_port" => $smtp_port,
          "smtp_user" => $smtp_user, 
          "smtp_pass" => $smtp_pass,
          "smtp_crypto" => "ssl",
          "mailtype" => "html",
          "charset" => "iso-8859-1",
          "wordwrap" => TRUE,
          "wordwrap" => "\r\n" //use double quotes to comply with RFC 822
        );

,您需要更改为

$config = Array(
          "protocol" => "smtp",
          "smtp_host" => $smtp_host,
          "smtp_port" => $smtp_port,
          "smtp_user" => $smtp_user, 
          "smtp_pass" => $smtp_pass,
          "smtp_crypto" => "ssl",
          "mailtype" => "html",
          "charset" => "iso-8859-1",
          "wordwrap" => TRUE,
          "crlf" => "\r\n" //use double quotes to comply with RFC 822
        );

我能看到的唯一的东西