gpt4 book ai didi

php - 当客户添加工单时,我想向在该部门工作的所有员工发送邮件

转载 作者:行者123 更新时间:2023-11-29 01:35:16 25 4
gpt4 key购买 nike

我有一个票务系统。因此,我希望每当用户创建新工单时,都会向在该部门工作的所有员工发送一封邮件。

以下是我的模型代码:

public function ticket_email() 
{

$query = $this->db->select('staff_sign_up.email')
->distinct('staff_sign_up.email')
->from('staff_sign_up')
->join('view_ticket','view_ticket.initial_department=staff_sign_up.department_id')
->get();
return $query->result();
}

此模型正在获取在该部门工作的那些员工的所有邮件 ID。

以下是我的 Controller 代码:

public function ticket_send() {
$subject = 'A Ticket has been added please check & reply asap';
$message = '
<h3 align="center">Ticket Details</h3>
<table border="1" width="100%" cellpadding="5">
<tr>
<td width="30%">Subject</td>
<td width="70%">' . $this->input->post("subject") . '</td>
</tr>
<tr>
<td width="30%">Description</td>
<td width="70%">' . $this->input->post("description") . '</td>
</tr>
</table>
';
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '******@gmail.com',
'smtp_pass' => '*******',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('manojit.chakraborty58@gmail.com', 'admin');
$this->email->to($this->auth_model->ticket_email());
$this->email->subject($subject);
$this->email->message($message);
if ($this->email->send()) {
$this->session->set_flashdata('message', 'Your ticket has been generated,please wait sometime for reply');
} else {
show_error($this->email->print_debugger());
}
}

因此, Controller 应该向在该部门工作的所有员工发送带有工单详细信息的邮件。

我有这些错误:

object of stdclass could not be converted into string

preg_match expects parameter 2 to be string but object given

我正在使用 CodeIgniter 3 并且是初学者。

在 Alex 的评论后编辑:

result_array 返回以下元素:-

Array ( [0] => Array ( [email] => *****@gmail.com ) [1] => Array ( [email] => *******@example.com ) [2] => Array ( [email] => *******@gmail.com ) [3] => Array ( [email] => ******@gmail.com ) )

Alex 最新更新后:

this is the output that's coming

最佳答案

您可以尝试将 smtp 主机更改为 ssl://smtp.gmail.com

关于php - 当客户添加工单时,我想向在该部门工作的所有员工发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51394887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com