在使用php发送电子邮件时没有配置错误
请在下面看到我的电子邮件发送代码,并在发送电子邮件时显示以下错误。
无法使用PHP邮件发送电子邮件()。 您的服务器可能未配置为使用此方法发送邮件。
我的控制器:
 $from_email= "******"; 
 $to_email = 'dummy@dummy.com';
 $subject='Password Reset Request';
 $htmlContent = '<p>'.$link.'</p>';
     $this->load->library('email'); 
     $config['mailtype'] = 'html';
     $this->email->initialize($config);
     $this->email->set_newline("rn"); 
     $this->email->from($from_email,'*****'); 
     $this->email->to($to_email);
     $this->email->subject($subject); 
     $this->email->message($htmlContent);           
     $this->email->send();
这种情况显示了上述错误。 实际上,它在开发阶段最初工作的很好,但现在不是。在这个查询中出现了什么问题......先谢谢了。
  你正在使用$this->email->initialize($config);  但是你的代码没有实际的配置。  并根据您的错误无法使用PHP邮件()发送电子邮件 ,您的服务器可以通过sendmail运行。 
编码器中的电子邮件类
例
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
用这个在服务器上检查外发邮件
 telnet google.com 25 # 587 or  2095 ,2096
大多数服务器输出端口将是25或587
如果你在本地主机的代码工作,你在现场服务器? 如果你的网址是siteurl.domain然后尝试,
    $from_email= "email@siteurl.domain";  //from email must be from same server url
    $to_email = 'dummy@dummy.com';
    $subject='Password Reset Request';
    $htmlContent = '<p>'.$link.'</p>';
    //{INCLUDE SMTP CONFIG HERE IF THIS NOT WORKiNG THIS METHOD}
    $config['mailtype']  = 'html';
    $config['charset']   = 'iso-8859-1';
    $config['wordwrap']  = TRUE;
    $config['newline']   = "rn"; //use double quotes
    $this->email->initialize($config);     
    $this->email->from('$from_email', 'sender name');   
    $this->email->to($to_email);
    $this->email->subject($subject);
    $this->email->message($htmlContent);
    $this->email->send();
其他尝试与SMTP :),
     //SMTP CONFIG
     $config['protocol']  = 'smtp';
     $config['smtp_host'] = 'ssl://smtp.gmail.com'; //smtp host name
     $config['smtp_port'] = '465'; //smtp port number
     $config['smtp_user'] = 'ji******@gmail.com';
     $config['smtp_pass'] = '*******'; //$from_email password
     //Continue above code
我无法评论(对不起):),有时SMTP方法不能与Bluehost帐户一起使用:(
链接地址: http://www.djcxy.com/p/69343.html上一篇: Getting not configured error while sending email in php
