Welcome Guest, Not a member yet? Register   Sign In
CI email (sendmail) support
#1

I've been trying to learn over the last few wks how to send mail via any of the several schemes I've attempted from examples both in the CI docs and from several StackOverflow posts that mostly deal with previous CI versions. But I've come up against a block for several days now. I'm not asking for a tutorial but can anyone point me to a good source that clearly and fully explains how to implement the sending of email messages from a CI coded application. 

I've tried basically everything I could find so far starting with the CI User Guide examples which use sendmail as mail client. This scheme would be my preferred configuration (just because it's the one in the CI User Guide). I'm currently getting:

Quote:Exit status code: 1
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.

In the User Guide config code:
Code:
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

$this->email->initialize($config);


I'm not sure what mailpath above refers to - I suspect that would be the path in some example directory structure. I have my 'sendmail' folder in an 'assets' folder under 'applications' in the CI directory. I'm trying to do this from my Mem_mail controller. My current attempt is:

Code:
<?php
   defined('BASEPATH') OR exit('No direct script access allowed');


    class Mem_mail extends CI_Controller {
        
        public function index() {   
            $this->load->helper(array('url','form'));
            $this->load->view('common/header');
            $this->load->view('mail_view');
            $this->load->view('common/footer');
            $this->sendMail();
        }  
        
        function sendMail() {
            $config = Array(
                'protocol' => 'sendmail',
                'mailpath' => 'base_url(assets/sendmail)',
                'mailtype' => 'html',
                'charset' => 'iso-8859-1',
                'wordwrap' => TRUE
            );
            $this->email->initialize($config);
                        
            $this->email->set_newline("\r\n");
            $this->email->from('xxx'); // change it to yours
            $this->email->to('xxx');// change it to yours
            $this->email->subject('Test Mssg');
            $message = 'This is a test message!';
            $this->email->message($message);
            if($this->email->send()) {
                echo 'Email sent.';
            }
            else {
                show_error($this->email->print_debugger());
            }

        }
 }

StackOverflow esp. is full of statements that it won't work unless you change this or that line in php.ini for example. And almost none of those suggestions agree.  Bit I'tried making changes. None worked so I undid the changes (I hope). 

Also, I'm trying to do this from 'localhost'. I've also seen SO comments with instructions to do this but also that it probably won't work. If that's the case how do I test CI email code to know it works before I start sending faulty messages in a production environment? Any help appreciated.
Reply


Messages In This Thread
CI email (sendmail) support - by codeguy - 05-26-2016, 10:25 AM
RE: CI email (sendmail) support - by cartalot - 05-26-2016, 01:09 PM
RE: CI email (sendmail) support - by codeguy - 05-26-2016, 02:42 PM
RE: CI email (sendmail) support - by PaulD - 05-26-2016, 09:40 PM
RE: CI email (sendmail) support - by codeguy - 11-01-2016, 06:38 AM
RE: CI email (sendmail) support - by InsiteFX - 11-01-2016, 07:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB