Hello i have a probleme with code igniter mail send here is my code
function __construct()
{
parent::__construct();
$this->load->library('email');
}
function index()
{
$this->load->library('email');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.mailtrap.io',
'smtp_port' => 2525,
'smtp_user' => 'edf81f6d31af91',
'smtp_pass' => '6d824154999158',
'crlf' => "\r\n",
'newline' => "\r\n"
);
$this->email->initialize($config);
$this->email->from('b8748b238c-54555a@inbox.mailtrap.io', 'Your Name');
$this->email->to('dadycool014@hotmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
}
and when i execute this code i get this error
A PHP Error was encountered Severity: Warning
Message: fsockopen():
Filename: libraries/Email.php
Line Number: 2055
Backtrace:
File: C:\xampp\htdocs\ctmprod\application\libraries\Email.php Line: 2055 Function: fsockopen
File: C:\xampp\htdocs\ctmprod\application\libraries\Email.php Line: 1950 Function: _smtp_connect
File: C:\xampp\htdocs\ctmprod\application\libraries\Email.php Line: 1825 Function: _send_with_smtp
File: C:\xampp\htdocs\ctmprod\application\libraries\Email.php Line: 1715 Function: _spool_email
File: C:\xampp\htdocs\ctmprod\application\controllers\email.php Line: 51 Function: send
File: C:\xampp\htdocs\ctmprod\index.php Line: 315 Function: require_once
function sesnd_mail()
{
$this->load->library('email');
$config = array();
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "smtp";
$config['smtp_host'] = "smtp.sendgrid.net";
$config['smtp_user'] = "username";
$config['smtp_pass'] = "password ";
$config['smtp_port'] = "25";
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->subject('TEST SUBJECT');
$this->email->message("THIS IS A TEST MESSAGE");
$this->email->from( "yyy@gmail.com" );
$this->email->to("xxx@gmail.com");
if($this->email->send())
{
echo "success";
}
else
{
echo $this->email->print_debugger();
}
}