Php Codeigniter应用程序中的可配置SMTP帐户
我想让用户编辑将在CodeIgniter web应用程序上发送通知的电子邮件帐户。我通常会使用类似于:Php Codeigniter应用程序中的可配置SMTP帐户,php,codeigniter,security,passwords,Php,Codeigniter,Security,Passwords,我想让用户编辑将在CodeIgniter web应用程序上发送通知的电子邮件帐户。我通常会使用类似于: $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'xxx', 'smtp_pass' =>
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx',
'smtp_pass' => 'xxx', // hardcoded unhashed password
'mailtype' => 'html',
'charset' => 'utf8'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
但这是硬编码的,不允许用户配置或编辑管理员的选项。我想从数据库中调用它,但是电子邮件密码将在表中公开(而不是散列),对吗
是否有其他方法使其可配置和安全?因为您需要通过SMTP传递原始密码,哈希密码将不起作用。您将需要使用双向加密。您可以使用codeigniter加密/解密类来提高安全性: 应该简单到:
$plain_text = 'This is a plain-text message!';
$ciphertext = $this->encryption->encrypt($plain_text);
// Outputs: This is a plain-text message!
echo $this->encryption->decrypt($ciphertext);
此外,询问GMAIL密码是相当不安全的。我希望使用OAUTH方法,让用户批准您的应用程序:所以使用
'smtp\u user'=>$this->post['post\u field\u here']
,或者将其存储在数据库中,稍后再检索。谢谢@FrankerZ。我的第一个想法是将其存储在数据库中,但我担心的是,它将不得不不加密地存储,对吗?我宁愿在数据库中没有普通密码。不管怎样,您都需要将密码传递到smpt.googlemail.com
。您可以使用codeigniter encryption/decryption类来提高安全性:将其存储在os环境变量中比存储在db中更安全,但不可配置。接受Double,因为1。加密将对常规SMTP密码存储2有所帮助。我仅以gmail为例,但现在我还将为OAUTH添加一个选项,如果用户将使用gmail或gSuite帐户。谢谢你@FrankerZ