当我通过codeigniter email library从Ubuntu Server 12.04 LTS VirtualBox VM中使用AWS SES发送电子邮件时,收到PHP警告(stream_socket_enable_crypto(): SSL/TLS already set-up for this stream
)。尽管出现警告,但电子邮件仍成功发送。
// /application/config/email.php:
$config['mailtype'] = 'html';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://email-smtp.us-west-2.amazonaws.com';
$config['smtp_user'] = 'OMITTED';
$config['smtp_pass'] = 'OMITTED';
$config['smtp_port'] = 465;
$config['newline'] = "\r\n";
$config['wordwrap'] = true;
$config['smtp_crypto'] = 'tls';
目前,我发送电子邮件的代码并不花哨:
$this->load->library('email');
$this->email->from('team@omitted.com', 'Team Omitted');
$this->email->to($person[0]['email']);
$this->email->subject('Temporary password');
$this->email->message('Here is your temporary password:<br />'.$new_pw);
if($this->email->send())
$return['success'] = true;
else
$return['err_msg'] = 'Failed to send password reset email. Please try again';
该警告到底告诉我什么,我该如何解决?提前谢谢!
最佳答案
当尝试在CodeIgniter中将SSL / TLS smtp crypto与Email librarie一起使用时,此解决了警告。
打开文件:/system/libraries/Email.php
然后,在_smtp_connect()函数中,您可以在代码上进行如下编辑:
if ($this->smtp_crypto == 'tls')
{
$this->_send_command('hello');
$this->_send_command('starttls');
if( strpos( $this->smtp_host, 'ssl://') === FALSE ) {
stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
}
}
函数stream_socket_enable_crypto的更多信息:http://php.net/manual/en/function.stream-socket-enable-crypto.php
关于php - CodeIgniter:流套接字已启用对此流警告设置的加密SSL/TLS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24110360/