我有使用codeigniter发送电子邮件的功能。当我通过浏览器在localhost计算机上运行时,此功能正常,但是当我尝试通过命令行界面运行时,此功能失败,这是我得到的日志:
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: "myemail@gmail.com" X-Sender: myemail@gmail.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <50f11a55932b7@gmail.com> Mime-Version: 1.0
请帮我解决这个错误
答案 0 :(得分:0)
您的php.ini文件中是否设置了邮件设置?你真的能够通过浏览器中的应用程序发送电子邮件吗?仅仅因为它没有抱怨并不意味着功能实际上有效。
答案 1 :(得分:0)
也许您没有该文件的授权访问权。
尝试使用此命令使所有用户都可以访问:
sudo chmod 777 /var/www/myapp/system/libraries/Log.php
这是一种不正确的使用方法,但你可以找到问题。
答案 2 :(得分:0)
然后像这样更改config / email.php:
$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']='myemail@gmail.com';
$config['smtp_pass']='mypassword';
$config['charset']='utf-8';
$config['newline']="\r\n";