我正在使用Codeigniter。在用户管理模块中,如果状态被激活,我想向用户发送电子邮件。我的电子邮件代码有效,但我的状况有问题,请检查他的状态是否已更改。我的意思是,仅当他的状态更改为“活动”时,我才想发送电子邮件。
以下是我的控制器代码:
if($_POST['status'] == 'active')
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'Myhost',
'smtp_port' => 25,
'smtp_user' => 'user',
'smtp_pass' => 'pass',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'Rajan');
$this->email->to($_POST['email']);
$this->email->subject('Your Account Has Been SuccessFully Activated.');
$this->email->message('Hi, We have created your Account. Please Login ');
$this->email->send();
if ($this->email->send())
{
echo"Success";
}
else
{
echo '<p class="error_msg">That Email And Password Combination Does Not Exist !</p>';
}
}
当我编辑用户并更改其状态时,它将保存在数据库中,但不会触发电子邮件。请帮助我解决此错误。
请尝试使用此方法,if($_POST['status'] == 'Active')
因为您的状态发布值为“有效”(根据我们的讨论)。(==)
当用于比较PHP中的字符串时,双等号区分大小写。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句