1

//send email function

public function sendemail(){

    $from1 = $this->input->post('from');//input name
    $to1 = $this->input->post('to');//input name
    $subject1 = $this->input->post('subject');//input name
    $message1 = $this->input->post('message');//input name
    $config = Array(
          'protocol' => 'smtp',
          'smtp_host' => 'ssl://smtp.googlemail.com',
          'smtp_port' => 465,
          'smtp_user' => 'malinga@bckonnect.com',
          'smtp_pass' => 'mal@pass',
          'mailtype' => 'html'
    );
    $this->load->library('email', $config);//load library Codeigniter
    $this->email->set_newline("\r\n");
    // Set to, from, message, etc.
    $this->email->to($to1);
    $this->email->from($from1,$from1);
    //$this->email->bcc("example2@domain.com"); 
    $this->email->subject($subject1);
    $this->email->message($message1);    
    $result = $this->email->send();

    $this->session->set_flashdata('msg','<div class="alert alert-success">Message Sent Successfully!</div>');
    redirect('welcome/index');

}

this is my email function code.it is working for gmail.but it is not working for Zoho mail.Why?

Yasas Malinga
  • 29
  • 1
  • 4

1 Answers1

0

You should add Zoho mail SMPT configuration:

Outgoing Server Name: smtp.zoho.com
Port: 465 with SSL or
Port: 587 with TLS
Require Authentication: Yes

So it will be like

 $config = Array(
          'protocol' => 'smtp',
          'smtp_host' => 'ssl://smtp.zoho.com',
          'smtp_port' => 465,
          'smtp_user' => 'malinga@bckonnect.com',
          'smtp_pass' => 'mal@pass',
          'mailtype' => 'html'
    );

Reference : https://www.zoho.com/mail/help/imap-access.html

Thamaraiselvam
  • 6,961
  • 8
  • 45
  • 71