"504 Gateway Time-out"when sending mail by SMTP in CodeIgniter

4712 단어 PHPCodeIgniter

What happened?


The source code:

$config['protocol'] = 'smtp';
$config['smtp_host'] = $this->config['smtp_host'];
$config['smtp_user'] = $this->config['smtp_user'];
$config['smtp_pass'] = $this->config['smtp_pass'];
$config['smtp_port'] = $this->config['smtp_port'];
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;

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

$this->_CI->email->from($from_email, $from_name);
$this->_CI->email->to($to);
$this->_CI->email->subject($subject);
$this->_CI->email->message($body);

return $this->_CI->email->send();
Same source code, different SMTP server and user/password, some server/user run out with the "504 Gateway Time-out"error:

It seems the action is depending on the SMTP servers.

How to fix this error?


Add these two lines in your code:
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
This will make it working.
reference:

좋은 웹페이지 즐겨찾기