【问题标题】:Codeigniter Email Sending IssueCodeigniter 电子邮件发送问题
【发布时间】:2016-08-12 06:09:25
【问题描述】:

这是链接: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

【问题讨论】:

  • 您确定该站点已配置为 SSL?我问是因为如果你去https://theartvalley.com/clients/theartvalley.com/ 你会得到一个“不安全”或“非私人”的错误页面——取决于所使用的浏览器。
  • @DFriend 如果站点配置为 SSL,应该没有任何区别。重要的是 SMTP 服务器是否配置了 SSL。
  • 根据您的配置,电子邮件库将尝试使用 ssl:// 传输打开域套接字连接。如果您的服务器的 PHP 没有启用 openssl 支持,则不会打开套接字(也就是连接重置)。
  • 我在做什么?我在非 ssl 站点中使用带有 ssl 的这种类型的代码,它可以工作,但没有。

标签: php codeigniter ssl


【解决方案1】:

我不明白您为什么需要其他库并对其进行扩展。

$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
        );

是我唯一能看到的东西

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-07
    • 2019-08-07
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 2020-03-27
    • 2011-08-13
    • 2012-12-16
    相关资源
    最近更新 更多