我在通过电子邮件发送的电子邮件类中发送电子邮件问题,在电子邮件中显示源HTML代码而不是呈现的HTML视图。为了进行测试,我目前在Windows上的XAMPP上使用CI,并使用Gmail SMTP发送到相同的Gmail地址。发送HTML电子邮件结果显示HTML源代码(Codeigniter电子邮件类)
发送电子邮件的功能如下:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => 'mygmailpassword',
);
$this->load->library('email', $config);
$this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->to($email);
$this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth')));
$this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
$this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));
$this->email->set_newline("\r\n"); // require this, otherwise sending via gmail times out
$this->email->send();
是没有问题越来越发送的文字版本。加载的视图是一个将通过电子邮件发送出去的html文件。
Welcome to <?php echo $site_name; ?>!Welcome to <?php echo $site_name; ?>!Thanks for joining <?php echo $site_name; ?>. We listed your sign in details below, make sure you keep them safe. To verify your email address, please follow this link: Link doesn't work? Copy the following link to your browser address bar: <?php echo site_url('/auth/activate/'.$user_id.'/'.$new_email_key); ?> Please verify your email within <?php echo $activation_period; ?> hours, otherwise your registration will become invalid and you will have to register again. <?php if (strlen($username) > 0) { ?>Your username: <?php echo $username; ?><?php } ?> Your email address: <?php echo $email; ?> <?php if (isset($password)) { /* ?>Your password: <?php echo $password; ?><?php */ } ?> Have fun! The <?php echo $site_name; ?> Team |
任何想法如何让HTML电子邮件发送呈现,而不是显示其源代码?
2011-06-08
Nyxynyx
+0
你不能有PHP在一封电子邮件中身体。我也不确定你需要或标签。 –
2011-06-08 04:13:13
+0
@Nik:PHP是*生成*发送的HTML,它实际上不在电子邮件正文中。 –
2011-06-08 04:16:41
+0
不是电子邮件中HTML的第二个代码段吗?那里有PHP。显然,第一个代码段是一代。 –
2011-06-08 04:18:41