0

my webiste is hosted in infinityfree and I tried send emails and I'm not receiving any. This is the code that I used

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxx',
    'smtp_pass' => 'xxx',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

Do I have to setup something in google or in the control panel of my website? thank you

geek_10101010
  • 90
  • 1
  • 4
  • 19

2 Answers2

1

This is the simplest way to send a email in codeigniter

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

$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();

By using this code, you can check the mail functionality. You can also follow the codeigniter email class Codeigniter email class

Indresh Tayal
  • 276
  • 1
  • 11
0

Try this First, load the library

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

$this->email->from('test@abc.com', 'Sender Name');
$this->email->to('to@gmail.com');
$this->email->subject('Sample');
$this->email->message('Email testing');

Use condition to check if email send or not

if($this->email->send()){
    echo 'Scuuess';
}else{
    echo 'Fail';
}
Danish Ali
  • 2,354
  • 3
  • 15
  • 26