CI框架有发送邮件类:具体的可以看手册,关于邮件的配置文件,我放在单独的文件里,方便以后维护
文件名为:email.php,这个文件保存到application/config/email.php,然后在控制器里加载$this->load->library('email'),这样就不需要使用$this->email->initialize()函数来初始化参数了
Php代码
<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = 'email地址';
$config['smtp_pass'] = '*******';
$config['mailtype'] = 'html';
$config['validate'] = true;
$config['priority'] = 1;
$config['crlf'] = "\r\n";
$config['smtp_port'] = 25;
$config['charset'] = 'gb2312';
$config['wordwrap'] = TRUE;
<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = 'email地址';
$config['smtp_pass'] = '*******';
$config['mailtype'] = 'html';
$config['validate'] = true;
$config['priority'] = 1;
$config['crlf'] = "\r\n";
$config['smtp_port'] = 25;
$config['charset'] = 'gb2312';
$config['wordwrap'] = TRUE;
视图关键代码:
Html代码
<form action="<?php echo base_url();?>content/sendMail.html" method="post">
<input type="hidden" name="number" value="<?php echo $this->uri->segment(3);?>" />
<input type="hidden" name="url" value="<?php echo