Php 简单邮件功能在codeigniter中不起作用
我在Codeigniter控制器中有这个发送邮件代码Php 简单邮件功能在codeigniter中不起作用,php,codeigniter,email,Php,Codeigniter,Email,我在Codeigniter控制器中有这个发送邮件代码 $config['useragent'] = 'CodeIgniter'; $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'utf-8'; $config['wordwrap'] = TRUE; $this->load->library('e
$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('mymail@yahoo.com', 'myname');
$this->email->to('testingmail@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing .');
$this->email->send();
echo $this->email->print_debugger();
但它显示
无法使用PHP mail()发送电子邮件。请帮助我解决此问题。检查您的PHP配置(PHP.ini)以获得正确的mail
值:
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail
注释/取消注释行取决于您的操作系统。
您可能还需要安装sendmail
实用程序。$this->load->library('email');
$this->load->library('email');
$this->email->from('');
$this->email->to('');
$this->email->subject('subject');
$this->email->set_mailtype('html');
$datas['title'] = "title";
$datas['footer'] = '© '.date("Y").' www.aaa.com All rights reserved';
$con1 = '
<p style="Calibri, Verdana, Ariel, sans-serif; font-size:11px; color:#666666"> Hello , </p>
<p class="commen_text" style="font:Calibri, Verdana, Ariel, sans-serif; font-size:11px;font-weight:normal; color:#666666;text-align:justify;">content here.</p>
';
$con2 ='
<p class="commen_text" style="font:Calibri, Verdana, Ariel, sans-serif; font-weight:normal;font-size:11px;color:#666666;text-align:justify;">Please download the attachement. </p>
<p style="border-bottom: 1px solid rgb(235, 235, 235); font-size: 1px; margin-top: 0px;"> </p>
';
$this->email->attach('/path/of/the/file');
$datas['content']=$con1.$con2;
$msg = $this->load->view('include/email_template', $datas, TRUE); // create base html file and echo title, content and footer there
$this->email->message($msg);
$this->email->send();
$this->email->from(“”);
$this->email->to(“”);
$this->email->subject('subject');
$this->email->set_mailtype('html');
$datas['title']=“title”;
$datas['footer']='©;'。日期(“Y”)“www.aaa.com保留所有权利”;
$con1=
您好
此处的内容
';
$con2=
请下载附件
';
$this->email->attach('/path/of/the/file');
$datas['content']=$con1.$con2;
$msg=$this->load->view('include/email_template',$datas,TRUE);//创建基本html文件,并在其中回显标题、内容和页脚
$this->email->message($msg);
$this->email->send();
我不知道为什么您仍然想使用邮件功能,而不是使用电子邮件类
您可以使用用户gmail smtp设置发送电子邮件。哪个更健壮
如果这只是为了测试,我建议你使用Mailtrap SMTP,它是免费的,只用于测试电子邮件
如果您想要一个lib,您可以使用以下内容:linux操作系统,我们正在使用的可能是您尚未在php.iniTry中配置邮件设置,以使用php本机mail()
函数发送邮件,并查看它是否有效。我已将$to写入“sample@gmail.com"; $主题=“测试邮件”$message=“你好!这是一封简单的电子邮件。”$from=”someonelse@example.com"; $headers=“From:”$从…起邮件($to、$subject、$message、$headers);但是我没有收到邮件,我正在使用Linuzzos。如何在中安装sendmail实用程序codeignter@Ammu你用什么发行版?有时用phpdesignerdw@Ammu不,我是问你关于Linux发行版的问题。如果你有任何疑问,请参考