简体   繁体   中英

Codeigniter SMTP error

I'm trying to send emails from my CodeIgniter application via Zoho SMTP server.

Here is the code: $this->load->library('email');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.zoho.com';
$config['smtp_user'] = '<username>';
$config['smtp_pass'] = '<password>';
$config['smtp_port'] = 465;
$config['smtp_crypto'] = 'ssl';
$config['mailtype'] = 'text';

$this->email->initialize($config);

$this->email->from('<mail>', '<name>');
$this->email->to('<mail>');
$this->email->subject("Test");

$this->email->message("Test message");

if(!$this->email->send()){
    echo $this->email->print_debugger();
}

And I get this output:

220 mx.zohomail.com SMTP Server ready July 12, 2018 10:58:40 AM PDT

hello: 250-mx.zohomail.com Hello [::1] (83.240.61.40 (83.240.61.40))
250-STARTTLS
250 SIZE 53477376

starttls: 220 Ready to start TLS.

hello: 250-mx.zohomail.com Hello [::1] (83.240.61.40 (83.240.61.40))
250-AUTH LOGIN PLAIN
250 SIZE 53477376

from: 250 Sender  OK

to: 250 Recipient  OK

data: 354 Ok Send data ending with .


quit: 

The following SMTP error was encountered:
The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

Date: Thu, 12 Jul 2018 19:58:40 +0200
From: <from>
Return-Path: <from>
To: me@jradl.cz
Subject: =?UTF-8?Q?Test?=
Reply-To: <from>
User-Agent: CodeIgniter
X-Sender: <from>
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <id>
Mime-Version: 1.0


Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Test message

(removed personal data)

I get the same message when trying to use Gmail SMTP servers or a different account. Can anybody help with this?

Using Windows 10, XAMPP, CodeIgniter 3.1.9.

好的,所以我通过添加以下行来解决此问题:

$this->email->set_newline("\r\n");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM