0

I have a problem like this.I want to send a mail from my web application so I put this in my controller.

$from_email = "[email protected]";
$to_email = "[email protected]";

//Load email library
$this->load->library('email');
$this->email->from($from_email, 'Info');
$this->email->to($to_email);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();

This web application is still running on localhost.I tried so many examples in the net and which have been posted in stack overflow tooo.But there was nothing on my mail.Email was not send.How can I get fix this?

Tharindu Sandaruwan
  • 195
  • 1
  • 2
  • 12

1 Answers1

0

Create config array

 $config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => '[email protected]',// your mail name
    'smtp_pass' => '*****',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
    'wordwrap' => TRUE
);

then

  $this->load->library('email', $config);

  $this->email->from('[email protected]', 'myname');//your mail address and name
  $this->email->to('[email protected]'); //receiver mail

  $this->email->subject('testing');
  $this->email->message($message);

  if($this->email->send()) //sending mail
  {
     echo 'Mail sent';
  }
  else
  { 
     print_r($this->email->print_debugger(), true);
  }

Configuration in sendmail.ini

path [xampp folder]\sendmail\sendmail.ini

Configurations

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=yourgmailpassword
[email protected]

open php.ini config file and search for[mail function]

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

Restart Server

Main Source

Param Bhat
  • 470
  • 1
  • 6
  • 17