Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 迅捷邮递公司';错误异常';带有消息';fopen(/tmp/…)无法打开流:权限被拒绝';_Php_Laravel_Shared Hosting_Swiftmailer - Fatal编程技术网

Php 迅捷邮递公司';错误异常';带有消息';fopen(/tmp/…)无法打开流:权限被拒绝';

Php 迅捷邮递公司';错误异常';带有消息';fopen(/tmp/…)无法打开流:权限被拒绝';,php,laravel,shared-hosting,swiftmailer,Php,Laravel,Shared Hosting,Swiftmailer,我已经在cpanel共享主机上部署了laravel应用程序 当使用ignMailclass发送电子邮件时,以下错误会随机发生。(有时会发送邮件,但有时会发生错误) 我联系了主机支持人员,他们说我需要更改默认的临时目录 在SwiftMailer软件包lib/preferences.php中,名为$tmp的变量设置为getenv('TMPDIR'),文件中的注释说明: // You can override the default temporary directory by setting the

我已经在
cpanel
共享主机上部署了
laravel
应用程序

当使用ign
Mail
class发送电子邮件时,以下错误会随机发生。(有时会发送邮件,但有时会发生错误)

我联系了主机支持人员,他们说我需要更改默认的临时目录

在SwiftMailer软件包
lib/preferences.php
中,名为
$tmp
的变量设置为
getenv('TMPDIR')
,文件中的注释说明:

// You can override the default temporary directory by setting the TMPDIR environment variable.
我试图以不同的方式设置
TMPDIR

1) .htaccess:
SetEnv TMPDIR/home/../laravel4/app/storage/my_temp

2) 在
app/start/global.php
app::before
回调函数中使用
php putenv
函数

3) 在使用
php putenv
函数设置$temp的行之前的
lib/preferences.php

但其中没有一个更改打开的文件的路径,并导致
无法打开流:权限被拒绝
错误

以下是
swiftmailer/lib/preferences.php

<?php

/****************************************************************************/
/*                                                                          */
/* YOU MAY WISH TO MODIFY OR REMOVE THE FOLLOWING LINES WHICH SET DEFAULTS  */
/*                                                                          */
/****************************************************************************/

$preferences = Swift_Preferences::getInstance();

// Sets the default charset so that setCharset() is not needed elsewhere
$preferences->setCharset('utf-8');

// Without these lines the default caching mechanism is "array" but this uses a lot of memory.
// If possible, use a disk cache to enable attaching large attachments etc.
// You can override the default temporary directory by setting the TMPDIR environment variable.

// The @ operator in front of is_writable calls is to avoid PHP warnings
// when using open_basedir
$tmp = getenv('TMPDIR');
if ($tmp && @is_writable($tmp)) {
    $preferences
        ->setTempDir($tmp)
        ->setCacheType('disk');
} elseif (function_exists('sys_get_temp_dir') && @is_writable(sys_get_temp_dir())) {
    $preferences
        ->setTempDir(sys_get_temp_dir())
        ->setCacheType('disk');
}

// this should only be done when Swiftmailer won't use the native QP content encoder
// see mime_deps.php
if (version_compare(phpversion(), '5.4.7', '<')) {
    $preferences->setQPDotEscape(false);
}

您需要检查试图写入目录的进程是否可以写入目录。您可以通过执行以下命令来验证流程使用的用户和组:

<?php
    echo getmyuid().':'.getmygid();
?>

托管提供商是否告诉您需要将临时目录更改到哪个目录?@lowerends否,但新临时目录的权限为755您可以调试当前设置的
TMPDIR
?您可以使用
dd($\u ENV['TMPDIR'])
。@lowerends就在$tmep赋值之前,它是我设置的值问题是
是可写的
返回
false
,目录权限是0755,即使我将其设置为0777
可写
仍然返回
false
,并导致执行
elseif
<?php
    echo getmyuid().':'.getmygid();
?>
chown -R user:group writable_directory/