Welcome Guest, Not a member yet? Register   Sign In
sending mail with Email library
#1

[eluser]enCODer[/eluser]
Hello,

I have a problem of sending email using the CI email class. The debugger shows this:

Quote:Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

From: "newsletter"
Return-Path:
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Email_Test?=
Testing the email class.

However, I have tried to send email using a simple mail function: mail('[email protected]','TEST','Testing 123'); and I do get an email in seconds. I do not know what is wrong here? Do you have some ideas?
#2

[eluser]Sbioko[/eluser]
Yes, I have an idea :-) Do you use sendmail? If yes, then simply do not use it :-)
#3

[eluser]enCODer[/eluser]
I think you are talking about function in CI helper, however, my code looks like this:

Code:
$this->load->library('email');
        $this->email->from('[email protected]', 'newsletter');
        $this->email->to('[email protected]');

        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');
       // mail('[email protected]','TEST','Testing 123');
        $this->email->send();
        echo $this->email->print_debugger();
#4

[eluser]Sbioko[/eluser]
No, no, no :-) This is not a function. Sendmail is a protocol(as I remember). CI can use sendmail, SMTP and native php mail way to send your emails.

Here is the complete code for solving your problem:
Code:
$config['protocol']='mail';
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('[email protected]', 'newsletter');
$this->email->to('[email protected]');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();

Please, test this and then tell me about your results.
#5

[eluser]enCODer[/eluser]
Oh... That was my mistake about that function name. I am quite new to this framework, so I thought you were talking about send_mail() function.

However, I have tried your option and still did not get email to the inbox. After that, as you showed me the cause of problem, I looked through CI documentation and I tried another 'sendmail' protocol which you had introduced earlier. You will not believe, but now it works with this one.

Thank you for your time and quick responses.
#6

[eluser]Sbioko[/eluser]
I'm feeling great, when I hear such responses for me :-) You can freely ask me about anything you want!




Theme © iAndrew 2016 - Forum software by © MyBB