将多个文件/图像附加到codeigniter中的my phpmailer函数
你好 我有一个表单,它用用户选择的id显示数据库中的所有信息,然后我有一个按钮,通过phpmailer将数据发送到所选用户的电子邮件。在这些信息中,我有上传到服务器的图像和数据库的文件路径 我不明白的是,当用户点击“向前呼叫”按钮时,我如何获得要与电子邮件一起发送的图像/文件 请你告诉我正确的方向,因为我读过的大部分文章都是针对单个文件/图像的,直接从目录中添加 我的看法 包含图像的文件夹 [ 数据库图像将多个文件/图像附加到codeigniter中的my phpmailer函数,php,html,codeigniter,phpmailer,Php,Html,Codeigniter,Phpmailer,你好 我有一个表单,它用用户选择的id显示数据库中的所有信息,然后我有一个按钮,通过phpmailer将数据发送到所选用户的电子邮件。在这些信息中,我有上传到服务器的图像和数据库的文件路径 我不明白的是,当用户点击“向前呼叫”按钮时,我如何获得要与电子邮件一起发送的图像/文件 请你告诉我正确的方向,因为我读过的大部分文章都是针对单个文件/图像的,直接从目录中添加 我的看法 包含图像的文件夹 [ 数据库图像 我的观点 ''' “width=“250”height=“250”> ''' 我的
我的观点
'''
“width=“250”height=“250”>
'''
我的控制器
''函数转发\u调用($id){
$data=数组(
“formTitle”=>“转发呼叫”,
“标题”=>“呼叫管理”
);
$this->load->library('form_validation');
$this->form_validation->set_rules('call_attended_by'、'call attended by'、'trim | required | callback_reason_for_update');
如果($this->form\u validation->run()==FALSE)
{
$data['supplier']=$this->admin_model->get_supplier_list();
$data['priority']=$this->admin_model->get_priority_level();
$data['camera']=$this->admin_model->get_camera();
$data[“data”]=$this->admin\u model->get\u current\u call(“”,,$id);
$results=$this->admin_model->get_supplier_list();
$data['files']=$this->admin\u model->get\u call\u images($id);
$this->load->view('frame/header_view');
$this->load->view('frame/sidebar_nav_view');
$this->load->view('helpdesk/forward_call',$data);
}
其他的
{
$message=“以下通话需要您的助手。
呼叫ID:“.$\u POST['ID']”;
日期呼叫记录在HTCC:“.$\u POST['Date\u Logged']”上。
技师确认的日期:“.$”POST[“记录的日期]”
技术员:“.$”POST[“呼叫”出席人]”
呼叫状态:“.$”POST[“呼叫状态]。”
呼叫状态:“.$\u POST['location']”,
呼叫优先级:“.$”POST[“优先级”]。”
设备类型:“.$”POST[“设备类型]”
呼叫描述:“.$”POST[“呼叫描述”]。”
发现错误:“.$\u POST['Fault\u Found']”,“
如果您需要任何进一步的帮助,请联系帮助台或“$\u POST['call\u attended\u by']”。
感谢HTCC帮助台团队!!”;
$subject=“HTCC呼叫助理”;
$this->admin\u model->send\u call($message,$subject,$\u POST['email']);
$this->admin\u model->forwarded\u call($id);
重定向(基本url(“管理/打开呼叫列表”);
}'''
转发呼叫
''函数转发\u调用($id=0)
{
//$this->load->helper('url');
$data=数组(
'id'=>this->input->post('id'),
'呼叫有人'=>$this->input->post('呼叫有人'),
“技术人员确认的日期”=>$this->input->post(“技术人员确认的日期”),
“优先级”=>this->input->post('priority_level'),
“供应商”=>$this->input->post('supplier1'),
'转发至'=>this->input->post('supplier1'),
“技术员电子邮件”=>$this->input->post(“技术员电子邮件”),
“转发日期”=>日期(“Y-m-d H:i:s”),
);
$message=“ID为“$\u POST['ID']”的呼叫将被转发到“$\u POST['supplier1]”。
如果您需要任何进一步的帮助,请联系“$\u POST['call\u attended\u by']”或帮助热线;
感谢HTCC帮助台团队!!”;
$subject=“HTCC帮助台”;
$this->admin\u model->send\u call($message,$subject,$\u POST['user\u email']);
$module=“帮助台”;
$activity=“呼叫转发”。$data['supplier'];
$this->insert_log($activity,$module);
如果($id==0){
返回$this->db->insert('tbl_calls',$data);
}否则{
$this->db->where('id',$id);
返回$this->db->update('tbl_calls',$data);
}
}'''
我的朋友
''函数发送\调用($message,$subject,$sendTo){
需要_once APPPATH.'libraries/mailer/class.phpmailer.php';
需要_once APPPATH.“libraries/mailer/class.smtp.php”;
需要_once APPPATH.'libraries/mailer/mailer_config.php';
包括APPPATH.libraries/mailer/template/template.php';
$mail=新的PHPMailer(true);
$mail->IsSMTP();
尝试
{
$mail->SMTPDebug=1;
$mail->SMTPAuth=true;
$mail->SMTPSecure='ssl';
$mail->Host=Host;
$mail->Port=端口;
$mail->Username=GUSER;
$mail->Password=GPWD;
$mail->SetFrom(GUSER,'Helpdesk');
$mail->Subject=“不回复-”$Subject;
$mail->IsHTML(true);
$mail->WordWrap=0;
$hello='hello团队,☺;';
$Thank=“
这是自动生成的电子邮件,请不要回复。
谢谢,
帮助热线
”;
$body=$hello.$message.$谢谢;
$mail->Body=$header.$Body.$footer;
$mail->AddAddress($sendTo);
如果(!$mail->Send()){
$error='Mail error:'。$Mail->ErrorInfo;
重新
My View
'''<div class="col-lg-12">
<ul class="gallery">
<?php foreach($files as $row):
$images = explode(',', $row->files);
foreach($images as $files):?>
<img src="<?= base_url() . "uploads/ob_images/$files"; ?>" width="250" height="250">
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
</div>
</div>'''
My Controller
'''function forward_call($id){
$data = array(
'formTitle' => 'Forward Call',
'title' => 'Call Management'
);
$this->load->library('form_validation');
$this->form_validation->set_rules('call_attended_by', 'Call Attendad By', 'trim|required|callback_reason_for_update');
if ($this->form_validation->run() === FALSE)
{
$data['supplier'] = $this->admin_model->get_supplier_list();
$data['priority'] = $this->admin_model->get_priority_level();
$data['camera'] = $this->admin_model->get_camera();
$data["data"] = $this->admin_model->get_current_call('', '', $id);
$results = $this->admin_model->get_supplier_list();
$data['files'] = $this->admin_model->get_call_images($id);
$this->load->view('frame/header_view');
$this->load->view('frame/sidebar_nav_view');
$this->load->view('helpdesk/forward_call', $data);
}
else
{
$message = "Your assistants is needed with the following call.<br><br>
<ins>Call ID:</ins> ".$_POST['id'].";<br><br>
<ins>Date Call Was Logged At HTCC:</ins> ".$_POST['date_logged']."<br><br>
<ins>Date Acknowledged By Technician:</ins> ".$_POST['date_logged']."<br><br>
<ins>Technician:</ins> ".$_POST['call_attended_by']."<br><br>
<ins>Call Status:</ins> ".$_POST['call_status']."<br><br>
<ins>Call Status:</ins> ".$_POST['location']."<br><br>
<ins>Call Priority:</ins> ".$_POST['priority_level']."<br><br>
<ins>Type Of Equipment:</ins> ".$_POST['type_of_equipment']."<br><br>
<ins>Call Description:</ins> ".$_POST['call_description']."<br><br>
<ins>Fault Found:</ins> ".$_POST['fault_found']."<br><br>
If you need any futher assists please contact Helpdesk or ".$_POST['call_attended_by']."<br><br>
Thanks HTCC Helpdesk Team!!";
$subject = "HTCC Call Assistants";
$this->admin_model->send_call($message,$subject,$_POST['email']);
$this->admin_model->forwarded_call($id);
redirect( base_url('admin/open_call_list'));
}'''
forward call
'''function forwarded_call($id = 0)
{
//$this->load->helper('url');
$data = array(
'id' => $this->input->post('id'),
'call_attended_by' => $this->input->post('call_attended_by'),
'date_acknowledged_by_tech' => $this->input->post('date_acknowledged_by_tech'),
'priority' => $this->input->post('priority_level'),
'supplier' => $this->input->post('supplier1'),
'forwarded_to' => $this->input->post('supplier1'),
'technician_email' => $this->input->post('technician_email'),
'date_forwarded' => date("Y-m-d H:i:s"),
);
$message = "The call with ID".$_POST['id']." you have logged will be forwarded to ".$_POST['supplier1']." .<br><br>
If you need any futher assists please contact ".$_POST['call_attended_by']." or Helpdesk;<br><br>
Thanks HTCC Helpdesk Team!!";
$subject = "HTCC Helpdesk";
$this->admin_model->send_call($message,$subject,$_POST['user_email']);
$module = "Helpdesk";
$activity = "Call Forwarded".$data['supplier'];
$this->insert_log($activity, $module);
if ($id == 0) {
return $this->db->insert('tbl_calls', $data);
} else {
$this->db->where('id', $id);
return $this->db->update('tbl_calls', $data);
}
}'''
My Phpmailer
'''function send_call($message,$subject,$sendTo){
require_once APPPATH.'libraries/mailer/class.phpmailer.php';
require_once APPPATH.'libraries/mailer/class.smtp.php';
require_once APPPATH.'libraries/mailer/mailer_config.php';
include APPPATH.'libraries/mailer/template/template.php';
$mail = new PHPMailer(true);
$mail->IsSMTP();
try
{
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = HOST;
$mail->Port = PORT;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom(GUSER, 'Helpdesk');
$mail->Subject = "DO NOT REPLY - ".$subject;
$mail->IsHTML(true);
$mail->WordWrap = 0;
$hello = '<h1 style="color:#333;font-family:Helvetica,Arial,sans-serif;font-weight:300;padding:0;margin:10px 0 25px;text-align:center;line-height:1;word-break:normal;font-size:38px;letter-spacing:-1px">Hello Team, ☺</h1>';
$thanks = "<br><br><i>This is autogenerated email please do not reply.</i><br/><br/>Thanks,<br/>Helpdesk<br/><br/>";
$body = $hello.$message.$thanks;
$mail->Body = $header.$body.$footer;
$mail->AddAddress($sendTo);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return array('status' => false, 'message' => $error);
} else {
return array('status' => true, 'message' => '');
}
}
catch (phpmailerException $e)
{
$error = 'Mail error: '.$e->errorMessage();
return array('status' => false, 'message' => $error);
}
catch (Exception $e)
{
$error = 'Mail error: '.$e->getMessage();
return array('status' => false, 'message' => $error);
}
}'''
$imageFolder = '/path/to/image/folder/';
$files = explode(',', $row['files']);
foreach ($files as $file) {
$mail->addAttachment($imageFolder . $file);
}