0
votes

I have function to send email with codeigniter. This function is Ok when I run in localhost computer via browser, but when I try to run via Command Line Interface, this function failed and this is log i got:

DEBUG - 2013-01-12 15:09:57 --> Config Class Initialized
    ERROR - 2013-01-12 15:09:57 --> Severity: Warning  --> chmod(): Operation not permitted /var/www/myapp/system/libraries/Log.php 106
    ....
    DEBUG - 2013-01-12 15:09:57 --> Database Driver Class Initialized
    ERROR - 2013-01-12 15:09:57 --> Severity: Warning  --> chmod(): Operation not permitted /var/www/myapp/system/libraries/Log.php 106
    DEBUG - 2013-01-12 15:09:57 --> Helper loaded: file_helper
    ERROR - 2013-01-12 15:09:57 --> Severity: Warning  --> chmod(): Operation not permitted /var/www/myapp/system/libraries/Log.php 106
    DEBUG - 2013-01-12 15:09:57 --> Email Class Initialized
    ERROR - 2013-01-12 15:09:57 --> Severity: Warning  --> chmod(): Operation not permitted /var/www/myapp/system/libraries/Log.php 106
    DEBUG - 2013-01-12 15:10:00 --> Language file loaded: language/english/email_lang.php
    ERROR - 2013-01-12 15:10:00 --> Severity: Warning  --> chmod(): Operation not permitted /var/www/myapp/system/libraries/Log.php 106
    DEBUG - 2013-01-12 15:10:00 --> Unable to send email using PHP mail().  Your server might not be configured to send mail using this method.
From: "TEST" 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

Please help me solve this error

3

3 Answers

0
votes

Do you have your mail settings set in your php.ini file? And are you really able to send emails through the app in your browser? Just because it doesn't complain doesn't mean the function actually works.

0
votes

Maybe you don't have grant access to the file.

Try to make accessible with all user with this command:

sudo chmod 777 /var/www/myapp/system/libraries/Log.php

It's a not right way to use it, but you can find the problem.

0
votes

Finally I can solve the problem myself According to here and here

And make change to config/email.php like this:

$config['protocol']='smtp';
$config['mailpath'] = "/usr/bin/msmtp";
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']=465;
$config['smtp_timeout']=30;
$config['smtp_user']='[email protected]';
$config['smtp_pass']='mypassword';
$config['charset']='utf-8';  
$config['newline']="\r\n";