tipask icon indicating copy to clipboard operation
tipask copied to clipboard

后台邮箱配置出问题

Open marryton007 opened this issue 5 years ago • 6 comments

版本:最新版 commit f4752c55553b70a778c00c4fb6d912e5e461c46d

错误页面: admin/setting/email

错误简述: Whoops, looks like something went wrong. ErrorException in Setting.php line 45: Array to string conversion

错误栈: in Setting.php line 45 at HandleExceptions->handleError('8', 'Array to string conversion', '/var/www/html/app/Models/Setting.php', '45', array('env_path' => '/var/www/html/.env', 'env_content' => 'APP_DEBUG=true APP_ENV=local APP_KEY=mnbl2zciiMg9qjFDaDzLAKIFUT2MR5Gv CONTENT_LENGTH=303 CONTENT_TYPE=application/x-www-form-urlencoded DB_DATABASE=tipaskx DB_HOST=db DB_PASSWORD=password1 DB_PORT=3306 DB_PREFIX=ask_ DB_USER=tipaskdb DB_USERNAME=tipaskdb DEVEL_KIT_MODULE_VERSION=0.3.0 DOCUMENT_ROOT=/var/www/html/public DOCUMENT_URI=/index.php FCGI_ROLE=RESPONDER GATEWAY_INTERFACE=CGI/1.1 GPG_KEYS=CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D HOME=/var/cache/nginx HOSTNAME=f4581309a5d8 HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3 HTTP_ACCEPT_ENCODING=gzip, deflate HTTP_ACCEPT_LANGUAGE=zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7 HTTP_CACHE_CONTROL=max-age=0 HTTP_CONNECTION=keep-alive HTTP_CONTENT_LENGTH=303 HTTP_CONTENT_TYPE=application/x-www-form-urlencoded HTTP_COOKIE=bmd__Session=72dbf41355aa22cda0b676c9b7932d6c; UM_distinctid=16c897725106d4-09e4718f94c8ff-37c153e-144000-16c89772511b71; CNZZDATA1273638993=1321489185-1565669051-http%253A%252F%252F192.168.106.128%253A8080%252F%7C1565674454; bmd__user_login=2LL7Xn6FE1RhNWMKTamI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.128:8008 HTTP_ORIGIN=http://192.168.106.128:8008 HTTP_REFERER=http://192.168.106.128:8008/admin/setting/email HTTP_UPGRADE_INSECURE_REQUESTS=1 HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36 LD_PRELOAD=/usr/lib/preloadable_libiconv.so php LUAJIT_INC=/usr/include/luajit-2.1 LUAJIT_LIB=/usr/lib LUA_MODULE_VERSION=0.10.14 MAIL_DRIVER=smtp MAIL_ENCRYPTION=ssl [email protected] MAIL_FROM_NAME=qiniu MAIL_HOST=smtp.163.com MAIL_OPEN=0 MAIL_PASSWORD=xxxxx! MAIL_PORT=465 MAIL_SENDMAIL=/usr/sbin/sendmail -bs [email protected] NGINX_VERSION=1.16.0 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PHPIZE_DEPS=autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c PHP_ASC_URL=https://www.php.net/get/php-7.3.8.tar.xz.asc/from/this/mirror PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 PHP_EXTRA_CONFIGURE_ARGS=--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi PHP_INI_DIR=/usr/local/etc/php PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie PHP_MD5= PHP_SELF=/index.php PHP_SHA256=f6046b2ae625d8c04310bda0737ac660dc5563a8e04e8a46c1ee24ea414ad5a5 PHP_URL=https://www.php.net/get/php-7.3.8.tar.xz/from/this/mirror PHP_VERSION=7.3.8 PWD=/var/www/html QUERY_STRING= REDIRECT_STATUS=200 REMOTE_ADDR=192.168.106.1 REMOTE_PORT=59545 REQUEST_METHOD=POST REQUEST_SCHEME=http REQUEST_TIME=1566270938 REQUEST_TIME_FLOAT=1566270938.8701 REQUEST_URI=/admin/setting/email SCRIPT_FILENAME=/var/www/html/public/index.php SCRIPT_NAME=/index.php SERVER_ADDR=172.29.0.4 SERVER_NAME=_ SERVER_PORT=80 SERVER_PROTOCOL=HTTP/1.1 SERVER_SOFTWARE=nginx/1.16.0 SHLVL=1 SUPERVISOR_ENABLED=1 SUPERVISOR_GROUP_NAME=php-fpm SUPERVISOR_PROCESS_NAME=php-fpm SUPERVISOR_SERVER_URL=unix:///dev/shm/supervisor.sock USER=nginx argc=0 ', 'value' => array(), 'key' => 'argv')) in Setting.php line 45 at Setting::writeToEnv() in SettingController.php line 67 at SettingController->email(object(Request)) at call_user_func_array(array(object(SettingController), 'email'), array(object(Request))) in Controller.php line 256 at Controller->callAction('email', array(object(Request))) in ControllerDispatcher.php line 164 at ControllerDispatcher->call(object(SettingController), object(Route), 'email') in ControllerDispatcher.php line 112 at ControllerDispatcher->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114 at ControllerDispatcher->callWithinStack(object(SettingController), object(Route), object(Request), 'email') in ControllerDispatcher.php line 68 at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Admin\SettingController', 'email') in Route.php line 203 at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134 at Route->run(object(Request)) in Router.php line 708 at Router->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AdminAuthenticate.php line 26 at AdminAuthenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AdminAuthenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Authenticate.php line 44 at Authenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Router.php line 710 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 674 at Router->dispatchToRoute(object(Request)) in Router.php line 635 at Router->dispatch(object(Request)) in Kernel.php line 236 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in VerifyCsrfToken.php line 50 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Kernel.php line 122 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87 at Kernel->handle(object(Request)) in index.php line 53

重现步骤: 在配置完邮箱信息后,点保存

marryton007 avatar Aug 20 '19 03:08 marryton007

部署方式

version: "2"
services:
  tipask:
    image: richarvey/nginx-php-fpm:1.7.4
    container_name: tipask
    restart: always
    environment:
      - DB_HOST=db
      - DB_DATABASE=tipaskx
      - DB_USER=tipaskdb
      - DB_PASSWORD=password1
      - TZ = 'Asia/Shanghai'  
    volumes:
      - ./config:/root/.composer
      - ./tipask:/var/www/html    # clone code from github
      - ./nginx:/etc/nginx/sites-enabled
      - ./php:/usr/local/etc/php   
    ports:
      - '8008:80'
    links:
      - db    
      - xunsearch
  
  db:
    image: mysql:5.7
    container_name: tipask-db
    environment:
      - MYSQL_DATABASE=tipaskx
      - MYSQL_USER=tipaskdb
      - MYSQL_PASSWORD=password1
      - MYSQL_ROOT_PASSWORD=password1
    volumes:
      - db:/var/lib/mysql
    restart: always
    ports:
      - 3306:3306
  
  xunsearch:
    image: hightman/xunsearch
    container_name: xunsearch
    #volumes:
    #  - search:/usr/local/xunsearch/data
    restart: always
    ports:
      - 8383:8383
      - 8384:8384

volumes:
  db:

marryton007 avatar Aug 20 '19 03:08 marryton007

手动修改一下.env配置文件 MAIL_SENDMAIL=/usr/sbin/sendmail -bs 修改为 MAIL_SENDMAIL='/usr/sbin/sendmail -bs' 新版本php对env配置项读取作调整了不允许空格,下个版本处理一下。

sdfsky avatar Aug 20 '19 03:08 sdfsky

奇怪,.env 没有这一项

APP_ENV=local
APP_DEBUG=true
APP_KEY=mnbl2zciiMg9qjFDaDzLAKIFUT2MR5Gv
DB_HOST=tipask-db
DB_PORT=3306
DB_DATABASE=tipaskx
DB_USERNAME=tipaskdb
DB_PASSWORD=password1
DB_PREFIX=ask_

marryton007 avatar Aug 20 '19 03:08 marryton007

如果不需要sendmail 命令行来发送邮件,先把sendmail去掉。

                         <div class="form-group sendmail @if ($errors->has('mail_sendmail')) has-error @endif">
                               <label for="mail_sendmail">SendMail命令配置</label>
                               <span class="text-muted">(设置SendMail命令配置)</span>
                               <input type="text" name="mail_sendmail" class="form-control " placeholder="/usr/sbin/sendmail -bs" value="{{ old('mail_sendmail',Setting()->get('mail_sendmail','/usr/sbin/sendmail -bs')) }}">
                               @if ($errors->has('mail_sendmail')) <p class="help-block">{{ $errors->first('mail_sendmail') }}</p> @endif
                           </div>

tipask/resources/views/admin/setting/email.blade.php 文件中去掉上面这一段代码,然后再保存。

sdfsky avatar Aug 20 '19 03:08 sdfsky

我现在不用sendmail发送邮件,就是走普通的SMTP服务,前面也没选sendmail方式。注释这段代码后,问题依然存在。

marryton007 avatar Aug 20 '19 03:08 marryton007

看前面的错误提示, 在数组里插入了太多的额外的信息,下面是系统的env命令结果,已经包含在其中了,还有一些其他的信息,都不知道怎么来的?

scheme@scheme-virtual-machine:~/dock/my-tipask/tipask$ docker exec -it tipask bash
bash-4.4# env
DB_HOST=db
LUAJIT_LIB=/usr/lib
php_vars=/usr/local/etc/php/conf.d/docker-vars.ini
HOSTNAME=f4581309a5d8
TZ = 'Asia/Shanghai'
PHPIZE_DEPS=autoconf            dpkg-dev dpkg           file            g++             gcc             libc-dev              make            pkgconf                 re2c
GPG_KEYS=CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D
NGINX_VERSION=1.16.0
DB_USER=tipaskdb
LUA_MODULE_VERSION=0.10.14
PHP_EXTRA_CONFIGURE_ARGS=--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
PHP_ASC_URL=https://www.php.net/get/php-7.3.8.tar.xz.asc/from/this/mirror
PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2
LUAJIT_INC=/usr/include/luajit-2.1
PWD=/var/www/html
HOME=/root
PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie
DB_PASSWORD=password1
php_conf=/usr/local/etc/php-fpm.conf
PHP_INI_DIR=/usr/local/etc/php
PHP_URL=https://www.php.net/get/php-7.3.8.tar.xz/from/this/mirror
PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2
TERM=xterm
PHP_VERSION=7.3.8
DEVEL_KIT_MODULE_VERSION=0.3.0
SHLVL=1
fpm_conf=/usr/local/etc/php-fpm.d/www.conf
PHP_MD5=
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PHP_SHA256=f6046b2ae625d8c04310bda0737ac660dc5563a8e04e8a46c1ee24ea414ad5a5
LD_PRELOAD=/usr/lib/preloadable_libiconv.so php
DB_DATABASE=tipaskx
_=/usr/bin/env
bash-4.4#

marryton007 avatar Aug 20 '19 04:08 marryton007