【问题标题】:Codeigniter stopped sending mails from gmail smtp on wamp server windows 10Codeigniter 停止在 wamp 服务器 windows 10 上从 gmail smtp 发送邮件
【发布时间】:2017-09-02 09:24:13
【问题描述】:

我发布的代码可以正常工作 2 个月。现在,由于某种原因,它停止发送邮件。

$config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'ssl://smtp.googlemail.com',
                'smtp_port' => 465,
                'smtp_user' => 'system@gmail.com',
                'smtp_pass' => 'xxxxxxx',
                'mailtype'  => 'html', 
                'charset'   => 'iso-8859-1'
            );
$this->load->library('email', $config);

//za da mi ispraka na sevisniot mail i da mozam da sledam dali ispraka izvestai dokolku oni stiklirale isprakanje
$this->email->clear(TRUE);  //za reset pred sekoe novo prakanje od jamkata
$this->email->set_newline("\r\n");

$this->email->from('doNotReply', '');
$this->email->to('service@gmail.com'); 

$this->email->subject($subjectStart . ' izvestaj');
$this->email->message('');  
$this->email->attach('D:/wamp64/www/dica/assets/iEksel/'. $filename);
if ( ! $this->email->send()){

    $myfile = fopen("mail.txt", "a") or die("Unable to open file!");
    $txt =  $this->email->print_debugger(); 
    fwrite($myfile, $txt); 
    fclose($myfile);

} 

调试器输出此错误:

遇到以下 SMTP 错误:0
无法发送数据:AUTH LOGIN
无法发送 AUTH LOGIN 命令。错误:
无法发送数据:MAIL FROM:
来自:遇到以下 SMTP 错误:无法发送数据:RCPT TO: to:遇到以下 SMTP 错误:无法发送数据:DATA

数据:遇到以下 SMTP 错误:无法发送数据:User-代理:CodeIgniter。
  
  

无法使用 PHP SMTP 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。

有谁知道为什么这段代码完美运行了 2 个月,现在却无法运行?

【问题讨论】:

    标签: smtp gmail windows-10 wamp codeigniter-2


    【解决方案1】:

    服务器端不需要此 smtp 代码。 对于服务器端,这么多代码就足够了:

            $this->load->library('email');
            $config['mailtype'] = 'html';
            $this->email->initialize($config);
            $this->email->to($this->input->post('emailtxt'));
            $this->email->cc($this->input->post('cctxt'));
            $this->email->from($fromEmail['user_email']);
            $this->email->subject($this->input->post('smailtxt'));
            $this->email->message($this->input->post('tamailtxt'));
            $this->email->attach($pathfile);
            $this->email->send();
    

    对于客户端,您使用的代码看起来可以找到。问题必须是 smtp 用户电子邮件和密码是否更改或检查 wamp 中的 php.ini 文件。

    【讨论】:

    • 这是我在 php.ini 中的,可以吗?: SMTP = localhost smtp_port = 25
    • 应该是这样的: SMTP=smtp.gmail.com smtp_port=465 sendmail_from = something@exmple.com sendmail_path = "\"E:\sendmail\sendmail.exe\" -t" 和在 sendmail/sendmail.ini 文件中是这样的: smtp_server=smtp.gmail.com smtp_port=465 smtp_ssl=auto force_sender=something@example.com
    • 但以前,我没有更改 php.ini 中的任何内容。就像我之前解释的那样,我从 codeigniter 完成了所有配置。那么为什么在成功工作 2 个月后它就停止工作了呢?
    • 我还注意到,无论我写什么值:'smtp_user' => 'system@gmail.com' 和 'smtp_pass' => 'xxxxxxx',我仍然得到同样的错误。
    • 从上面更改本地主机它正在工作。必须进行此更改。
    【解决方案2】:

    在数组中使用 smtps 代替 smtp。

    $config = Array(
     'protocol' => 'smtps',
     'smtp_host' => 'ssl://smtp.googlemail.com',
     'smtp_port' => 465,
     'smtp_user' => 'system@gmail.com',
     'smtp_pass' => 'xxxxxxx',
     'mailtype'  => 'html', 
     'charset'   => 'iso-8859-1'
    );
    

    【讨论】:

      猜你喜欢
      • 2012-10-20
      • 1970-01-01
      • 2014-10-15
      • 2014-01-24
      • 2016-08-06
      • 1970-01-01
      • 2011-10-21
      • 2016-09-07
      • 2017-11-18
      相关资源
      最近更新 更多