【发布时间】:2017-01-22 01:03:21
【问题描述】:
尝试发送电子邮件,但它的邮寄格式是 HTML 源代码。 这是我的控制器-
$config = Array(
'protocol' => 'SMTP',
'smtp_host' => 'hostname',
'smtp_port' => 'portname',
'smtp_user' => 'abn@gmail.com',
'smtp_pass' => '***',
'smtp_timeout' => '4',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('devendra@gmail.com', 'ABC');
$data = array(
'userName'=> $this->input->post('email'),
'password'=> $this->input->post('password'),
'EmpName'=> $this->input->post('name'),
'Number'=> $this->input->post('number'),
'City'=> $this->input->post('city'),
'State'=> $this->input->post('email'),
'Address'=> $this->input->post('address')
);
$this->email->to($this->input->post('email'));
$Subject = 'User Login Details';
$this->email->subject($Subject);
$body = $this->load->view('mailFormat.php',$data,TRUE);
$this->email->message($body);
$this->email->send();
和电子邮件格式页面mailFormat.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Employee Registration</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div>
<div style="font-size: 26px;font-weight: 700;letter-spacing: -0.02em;line-height: 32px;color: #41637e;font-family: sans-serif;text-align: center" align="center" id="emb-email-header"><img style="border: 0;-ms-interpolation-mode: bicubic;display: block;Margin-left: auto;Margin-right: auto;max-width: 152px" src="<?php echo base_url(); ?>/images/logo.png" alt="WFT" width="152" height="108"></div>
<p style="Margin-top: 0;color: #565656;font-family: Georgia,serif;font-size: 16px;line-height: 25px;Margin-bottom: 25px">Hey <?php echo $EmpName;?>,</p>
<p>Email Id - <?php echo $userName; ?> </p>
<p>Password - <?php echo $password; ?> </p>
<p>Contact Number - <?php echo $Number; ?> </p>
<p>City - <?php echo $City; ?> </p>
<p>State - <?php echo $State; ?> </p>
<p>Address - <?php echo $Address; ?> </p>
</div>
</body>
</html>
已发送电子邮件。但是显示 HTML 源代码的电子邮件格式。如何将其更改为 HTML 格式的电子邮件。
【问题讨论】:
-
我正在使用 codeIgniter 电子邮件库。你能告诉我吗?如何写上面的代码@cakil
-
抱歉,我错了,那么@Snickers 可能有答案
-
@cakil 您已将此问题标记为重复。
标签: php codeigniter email codeigniter-3