首先,我要感谢StackOVerflow及其用户帮助我解决许多技术问题.我今天创建了这个帐户,因为我看不到类似的问题.
问题 – 我遇到了在PHP CodeIgniter中发送电子邮件的问题.函数$this-> email-> send()每次执行大约需要3-4秒.
我们有一个社交平台,用户来这里发布东西.每次用户上传新更新时,我们都希望向他/她发送电子邮件.
问题是发送电子邮件功能需要大约3-4秒,我们希望在1秒内将其降低.
有没有什么方法可以并行执行发送电子邮件流程?假设一个python代码连续运行以获取新更新并向这些用户发送电子邮件.还有比这更好的方法吗?
技术堆栈 – PHP CI,MySQL,Apache,Windows
这是每次更新时调用的电子邮件代码 –
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => 587,
'smtp_user' => 'mailid@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'utf-8',
'smtp_crypto' => "tls"
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->set_mailtype("html");
$this->email->from('mailid@gmail.com', 'Support');
$this->email->to($this->session->userdata['email']);
$this->email->subject('You have posted a new update');
$this->email->message('Please login to check your new update. Do not reply to this email. For any issues reach out to email@emailid.com');
if (!$this->email->send())
{
show_error($this->email->print_debugger());
}
else
{
echo true;
}