当我使用codeigniter email library Ubuntu Server 12.04 LTS通过我的VirtualBox VM发送电子邮件时,我收到了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';
警告到底是什么告诉我,我该如何解决? Thx提前!
答案 0 :(得分:4)
在尝试使用CodeIgniter中的Email librarie使用SSL / TLS smtp加密时解决警告。
打开文件:/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