Getting not configured error while sending email in php
Please see my email sending code below and it is showing the following error while sending the email..
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
My Controller:
$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 condition is showing the above error. Actually, it was working fine initially in development stage, but now it is not..What could have gone wrong in this query...Thank you in advance..
you're using $this->email->initialize($config);
but there is no actual configs on your code. And as per your error Unable to send email using PHP mail() , your server can run through sendmail .
Email Class in codeingiter
Example
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
To check outgoing mail with this on server
telnet google.com 25 # 587 or 2095 ,2096
Most server outgoing ports will be 25 or 587
if you are in localhost the code work, are you in live server ? if your URL is siteurl.domain then try ,
$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();
else try with 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
I'm not able to comment(sorry) :), sometimes SMTP method not working with Bluehost account :(
链接地址: http://www.djcxy.com/p/69344.html上一篇: 用Beefree的PHPMailer发送一个奇特的邮件
下一篇: 在使用php发送电子邮件时没有配置错误