Codeigniter如何创建电子邮件的html模板
我使用下面的代码从基于codeigniter的网站的联系人表单发送电子邮件,为此,我在控制器中使用下面的代码Codeigniter如何创建电子邮件的html模板,codeigniter,email,templates,Codeigniter,Email,Templates,我使用下面的代码从基于codeigniter的网站的联系人表单发送电子邮件,为此,我在控制器中使用下面的代码 $entrydata['name']= $this->input->post('name'); $entrydata['email']= $this->input->post('email'); $entrydata['phone']= $this->input->post('phone'); $entrydata['m
$entrydata['name']= $this->input->post('name');
$entrydata['email']= $this->input->post('email');
$entrydata['phone']= $this->input->post('phone');
$entrydata['message']= $this->input->post('message');$msg = 'Email has sent successfully';
$data['reset'] = TRUE;
$this->load->library('email');
$this->email->from(set_value('email'), set_value('name'));
$this->email->to('my@webs.com');
$this->email->subject("Get a quote enquiry");
$all = 'Name:' . set_value('name') ."\n". 'Email :' .' '. set_value('email') ."\n".'Phone :' .' '. set_value('phone') ."\n".'Message :' .' '. set_value('message'); $this->email->message($all);
$s=$this->email->send();
$data['message'] = $msg;
有人知道如何添加自定义电子邮件模板来保存我的conact表单信息吗?这是我已经完成的一个示例
$data['map_to']=$this->input->post('map_to');
$event=$this->db->query("query");
if($event->num_rows()>0)
{
$data['event']=$event->row();
$data['map_from']=$event->row()->address2;
}
else
{
$data['event']=NULL;
}
$data['sender_mail'] = 'xx@xx.org';
$this->load->library('email');
$config = array (
'mailtype' => 'html',
'charset' => 'utf-8',
'priority' => '1'
);
$this->email->initialize($config);
$this->email->from($data['sender_mail'], 'xxxx');
$this->email->to($mail);
$this->email->subject('Map Location');
$message=$this->load->view('map_mail_format',$data,TRUE);
$this->email->message($message);
$this->email->send();
在这里,我加载一个名为
map\u mail\u format
的视图页面,并将值传递给该视图页面($data
),然后将该视图页面分配给一个变量,然后发送带有该消息的邮件。首先,您需要将配置初始化为
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
加载电子邮件库后,您可以将电子邮件视图存储到变量并将其发送
$mailbody = $this->load->view('myfile', $data, true);
您可以试试这个
$this->load->helper(array('email'));
$this->load->library(array('email'));
$this->email->set_mailtype("html");
您正在发送HTML格式的电子邮件吗?@bhushan是。。这包括我的联系人表单数据。从视图创建模板的想法对我来说是新的+我为此付1英镑