Laravel 错误异常与消息“一起引发”;出于安全原因,已禁用mail()

Laravel 错误异常与消息“一起引发”;出于安全原因,已禁用mail(),laravel,smtp,mailer,laravel-mail,Laravel,Smtp,Mailer,Laravel Mail,我正试图建立一个laravel网站,我已经能够得到一些工作,但我后来经历了这个错误 出于安全原因,已禁用mail() 我曾尝试联系我的主机提供商来帮助激活该功能,但他们拒绝了我,说他们无法激活该功能,我应该尝试修改邮件的标题,这样就不需要了 请问我如何才能做到这一点,因为我不是一个专家,当谈到邮件php 以下是我的错误: ErrorException thrown with message "mail() has been disabled for security reasons&q

我正试图建立一个laravel网站,我已经能够得到一些工作,但我后来经历了这个错误

出于安全原因,已禁用mail()

我曾尝试联系我的主机提供商来帮助激活该功能,但他们拒绝了我,说他们无法激活该功能,我应该尝试修改邮件的标题,这样就不需要了

请问我如何才能做到这一点,因为我不是一个专家,当谈到邮件php

以下是我的错误:

ErrorException thrown with message "mail() has been disabled for security reasons"

Stacktrace:
#57 ErrorException in /home/zcashcom/public_html/invest/core/app/Http/helpers/helpers.php:19
#56 mail in /home/zcashcom/public_html/invest/core/app/Http/helpers/helpers.php:19
这是文件helpers.php的完整代码

<?php

use App\General;
use App\User;
use App\MemberExtra;

function send_email($to, $subject, $name, $message){
        $general = General::first();
        
    if ($general->email_nfy == 1){
         $headers = "From: ".$general->web_title." <".$general->esender."> \r\n";
        $headers .= "Reply-To: ".$general->web_title." <".$general->esender."> \r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        
        $template = $general->emessage;
        $mm = str_replace("{{name}}",$name,$template);
        $message = str_replace("{{message}}",$message,$mm);
         mail($to, $subject, $message, $headers);
        }else {
        return;
    }
}

function send_sms( $to, $message){
    $gnl = General::first();
    if($gnl->sms_nfy == 1) {
        $sendtext = urlencode("$message");
        $appi = $gnl->smsapi;
        $appi = str_replace("{{number}}",$to,$appi);
        $appi = str_replace("{{message}}",$sendtext,$appi);
        $result = file_get_contents($appi);
      }
      return;
}



function updateDepositBV($id, $deposit_amount)
{
    while($id !="" || $id != "0") {
        if(isMemberExists($id))
        {
            $posid = getParentId($id);
            if($posid == "0")
                break;
            $position = getPositionParent($id);
            $currentBV = MemberExtra::where('user_id', $posid)->first();

            if($position == "L"){
                $new_lbv = $currentBV->left_bv + $deposit_amount ;
                $new_rbv = $currentBV->right_bv;
            }else{
                $new_lbv = $currentBV->left_bv;
                $new_rbv = $currentBV->right_bv + $deposit_amount ;
            }

            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_bv' => $new_lbv,
                   'right_bv' => $new_rbv,
                ]);

            $id = $posid;

        } else {
            break;
        }

    }//while
    return 0;
}



function updatePaid($id){
    while($id!=""||$id!="0"){
        if(isMemberExists($id)) {
            $posid=getParentId($id);
            if($posid  == "0")
                break;
            $position = getPositionParent($id);

            $currentCount = MemberExtra::where('user_id',$posid )->first();

            $new_lpaid = $currentCount->left_paid;
            $new_rpaid = $currentCount->right_paid;
            $new_lfree = $currentCount->left_free;
            $new_rfree = $currentCount->right_free;

            if($position == "L") {
                $new_lfree = $new_lfree-1;
                $new_lpaid = $new_lpaid+1;
            }else {
                $new_rfree = $new_rfree-1;
                $new_rpaid = $new_rpaid+1;
            }

            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_paid' => $new_lpaid,
                   'right_paid' => $new_rpaid,
                   'left_free' => $new_lfree,
                   'right_free' => $new_rfree,
                ]);
            $id =$posid;

        } else {
            break;
        }
    }
    return 0;
}






function treeeee($id ='', $uid=''){

    while($id!=""||$id!="0") {
        if(isMemberExists($id)){
            $posid=getParentId($id);
            if($posid=="0")
                break;
            if($posid==$uid){
                return true;
            }
            $id =$posid;
        } else {
            break;
        }
    }//while
    return 0;
}

function printBV($id){
    $cbv = MemberExtra::where('user_id', $id)->first();
    $rid = User::whereId($id)->first();
    $rnm = User::where('id', $rid->referrer_id)->first();
    echo "<b>Referred By:</b> $rnm->username <br>";
    echo "<b>Current BV:</b> L-$cbv->left_bv | R-$cbv->right_bv <br>";
}

function printBelowMember($id){
    $bmbr = MemberExtra::where('user_id', $id)->first() ;
    echo "<b>Paid Member Below:</b> L-$bmbr->left_paid | R-$bmbr->right_paid <br>";
    echo "<b>Free Member Below:</b> L-$bmbr->left_free | R-$bmbr->right_free <br>";
}

function updateMemberBelow($id='', $type=''){
    while($id!=""||$id!="0") {
        if(isMemberExists($id)) {
            $posid=getParentId($id);
            if($posid=="0")
                break;
            $position=getPositionParent($id);
            $currentCount = MemberExtra::where('user_id', $posid)->first() ;

            $new_lpaid = $currentCount->left_paid;
            $new_rpaid = $currentCount->right_paid;
            $new_lfree = $currentCount->left_free;
            $new_rfree = $currentCount->right_free;

            if($position=="L") {
                if($type=='FREE'){
                    $new_lfree = $new_lfree + 1;
                }else{
                    $new_lpaid = $new_lpaid+1;
                }
            }else {
                if($type=='FREE'){
                    $new_rfree = $new_rfree + 1;
                }else{
                    $new_rpaid = $new_rpaid+1;
                }
            }
            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_paid' => $new_lpaid,
                   'right_paid' => $new_rpaid,
                   'left_free' => $new_lfree,
                   'right_free' => $new_rfree,
                ]);
            $id =$posid;
        } else{
            break;
        }
    }
    return 0;
}

function getParentId($id){

    $count = User::whereId($id)->count() ;
    $posid = User::whereId($id)->first();
    if ($count == 1){
        return $posid->posid;
    }else{
        return 0;
    }
}


function getPositionParent($id){

    $count = User::whereId($id)->count();
    $position = User::whereId($id)->first() ;
    if ($count == 1){
        return $position->position;
    }else{
        return 0;
    }
}


function getLastChildOfLR($parentid ,$position){

    $childid = getTreeChildId($parentid, $position);

    if($childid!="-1"){
        $id = $childid;
    } else {
        $id = $parentid;
    }
    while($id!=""||$id!="0") {
        if(isMemberExists($id)) {
            $nextchildid = getTreeChildId($id, $position);
            if($nextchildid == "-1"){
                break;
            }else{
                $id = $nextchildid;
            }
        }else break;
    }
    return $id;
}
function getTreeChildId($parentid ,$position){
    $cou = User::where('posid', $parentid)->where('position', $position)->count();
    $cid = User::where('posid', $parentid)->where('position', $position)->first();
    if ($cou == 1){
        return $cid->id;
    }else{
        return -1;
    }
}

function isMemberExists($id){
    $count = User::where('id', $id)->count();
    if ($count == 1){
        return true;
    }else{
        return false;
    }
}

function Short_Text($data,$length){
    $first_part = explode(" ",$data);
    $main_part = strip_tags(implode(' ',array_splice($first_part,0, $length)));
    return $main_part ."...." ;
}

function ImageCheck($ext){
    if($ext != 'jpg' && $ext != 'jpeg' && $ext != 'png' && $ext != 'bnp'){
        $ext = "";
    }
    return $ext;
}

function NewFile($name, $data){
    $fh = fopen($name, "w");
    fwrite($fh,$data);
    fclose($fh);
}

function ViewFile($name){
    $fh = fopen($name, "r");
    $data = fread($fh,filesize($name));
    fclose($fh);
    return $data;
}

function Find_fist_int($string){
    preg_match_all('!\d+!', $string, $matches);
    if($matches[0] != ""){
        foreach($matches[0] as $key => $value){
            $url = $value;
            return $url;
            break;
        }
    }
}

function Replace($data) {
    $data = str_replace("'", "", $data);
    $data = str_replace("!", "", $data);
    $data = str_replace("@", "", $data);
    $data = str_replace("#", "", $data);
    $data = str_replace("$", "", $data);
    $data = str_replace("%", "", $data);
    $data = str_replace("^", "", $data);
    $data = str_replace("&", "", $data);
    $data = str_replace("*", "", $data);
    $data = str_replace("(", "", $data);
    $data = str_replace(")", "", $data);
    $data = str_replace("+", "", $data);
    $data = str_replace("=", "", $data);
    $data = str_replace(",", "", $data);
    $data = str_replace(":", "", $data);
    $data = str_replace(";", "", $data);
    $data = str_replace("|", "", $data);
    $data = str_replace("'", "", $data);
    $data = str_replace('"', "", $data);
    $data = str_replace("?", "", $data);
    $data = str_replace("  ", "_", $data);
    $data = str_replace("'", "", $data);
    $data = str_replace(".", "-", $data);
    $data = strtolower(str_replace("  ", "-", $data));
    $data = strtolower(str_replace(" ", "-", $data));
    $data = strtolower(str_replace(" ", "-", $data));
    $data = strtolower(str_replace("__", "-", $data));
    return str_replace("_", "-", $data);
}
php:87

<?php

namespace App\Http\Controllers\Auth;

use App\ChargeCommision;
use App\Income;
use App\MemberExtra;
use App\User;
use App\General;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
            'referrer_id' => 'required',
            'position' => 'required',
            'first_name' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/'],
            'last_name' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/'],
            'birth_day' => 'required',
            'mobile' => 'required',
            'street_address' => 'required',
            'city' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/'],
            'post_code' => 'required|numeric|min:0',
            'country' => 'required',
            'username' => 'required',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {

        $pin = substr(time(), 4);

        $ref_id = $data['referrer_id'];
        $poss = $data['position'];
        $posid =  getLastChildOfLR($ref_id,$poss);

        // $general = General::first();

         $message = '<tr>';
         $message .='<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">';
         $message .='<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;color:green;">Our warmest congratulations on your new account opening! This only shows that you have grown your business well. I pray for your prosperous.</p>';
                       
         $message .='<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">You have taken this path knowing that you can do it. Good luck with your new business. I wish you all the success and fulfillment towards your goal.</p>';
         $message .='<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Your username is '.$data['username'].' .</p>';

         $message .='<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Your password is '.$data['password'].' .</p>';

          $message .='<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px; color:red;">Remember, never share your password with otherone. And you are agree with our Terms and Policy.</p>';
          $message .='</td>';
          $message .='</tr>';

       send_email($data['email'], 'Account Created Successfully', $data['first_name'], $message);

        $sms =  'Congratulation, for registration. Your username is '.$data['username'].'. Your password is '.$data['password'].'';
        send_sms($data['mobile'], $sms);

        return User::create([
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'referrer_id' => $data['referrer_id'],
            'position' => $data['position'],
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'mobile' => $data['mobile'],
            'street_address' => $data['street_address'],
            'city' => $data['city'],
            'post_code' => $data['post_code'],
            'country' => $data['country'],
            'username' => $data['username'],
            'birth_day' =>  date('Y-m-d',strtotime($data['birth_day'])),
            'join_date' => Carbon::today(),
            'balance' => 0,
            'status' => 1,
            'paid_status' => 0,
            'ver_status' => 0,
            'ver_code' => $pin,
            'forget_code' => 0,
            'posid' => $posid,
            'tauth' => 0,
            'tfver' => 1,
            'emailv' => 0,
            'smsv' => 1,
        ]);
    }

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();
        event(new Registered($user = $this->create($request->all())));
        $this->guard()->login($user);
        MemberExtra::create([
           'user_id' => $user['id'],
           'left_paid' => 0,
           'right_paid' => 0,
           'left_free' => 0,
           'right_free' => 0,
           'left_bv' => 0,
           'right_bv' => 0,
        ]);
        updateMemberBelow($user['id'], 'FREE');
        return $this->registered($request, $user)
            ?: redirect($this->redirectPath());
    }
}

如果邮件因安全原因被停用,则不应使用它。事实上,如果你搜索这个主题,你会发现一些严重的结果,为什么你不应该使用它

我希望你和你的主人有一个电子邮件帐户,对吗?那么你为什么不想使用laravel的邮件功能呢

在.env文件中,您为电子邮件帐户设置了正确的参数:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=name@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
有时还需要定义MAIL_FROM_ADDRESS参数。如果不确定,可以在config的mail.php文件中找到所有可能的配置选项

然后,要使用Laravel发送电子邮件,您可以执行以下操作

Mail::raw('your message', function ($message) use ($request) {

    $message->to('email@receiver.com');
    $message->from('youremail@sender.com');
    $message->subject("Email subject");
});
我不知道你想达到什么目的,但如果你只想发送一些简单的信息,也许你应该使用laravel通知

<?php
//edited
use App\General;
use App\User;
use App\MemberExtra;

function send_email($to, $subject, $name, $message){
        $general = General::first();
        
    if ($general->email_nfy == 1){
         $headers = "From: ".$general->web_title." <".$general->esender."> \r\n";
        $headers .= "Reply-To: ".$general->web_title." <".$general->esender."> \r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        
        $template = $general->emessage;
        $mm = str_replace("{{name}}",$name,$template);
        $message = str_replace("{{message}}",$message,$mm);
        //mail($to, $subject, $message, $headers);
        }else {
        return;
    }
}

function send_sms( $to, $message){
    $gnl = General::first();
    if($gnl->sms_nfy == 1) {
        $sendtext = urlencode("$message");
        $appi = $gnl->smsapi;
        $appi = str_replace("{{number}}",$to,$appi);
        $appi = str_replace("{{message}}",$sendtext,$appi);
        $result = file_get_contents($appi);
      }
      return;
}



function updateDepositBV($id, $deposit_amount)
{
    while($id !="" || $id != "0") {
        if(isMemberExists($id))
        {
            $posid = getParentId($id);
            if($posid == "0")
                break;
            $position = getPositionParent($id);
            $currentBV = MemberExtra::where('user_id', $posid)->first();

            if($position == "L"){
                $new_lbv = $currentBV->left_bv + $deposit_amount ;
                $new_rbv = $currentBV->right_bv;
            }else{
                $new_lbv = $currentBV->left_bv;
                $new_rbv = $currentBV->right_bv + $deposit_amount ;
            }

            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_bv' => $new_lbv,
                   'right_bv' => $new_rbv,
                ]);

            $id = $posid;

        } else {
            break;
        }

    }//while
    return 0;
}



function updatePaid($id){
    while($id!=""||$id!="0"){
        if(isMemberExists($id)) {
            $posid=getParentId($id);
            if($posid  == "0")
                break;
            $position = getPositionParent($id);

            $currentCount = MemberExtra::where('user_id',$posid )->first();

            $new_lpaid = $currentCount->left_paid;
            $new_rpaid = $currentCount->right_paid;
            $new_lfree = $currentCount->left_free;
            $new_rfree = $currentCount->right_free;

            if($position == "L") {
                $new_lfree = $new_lfree-1;
                $new_lpaid = $new_lpaid+1;
            }else {
                $new_rfree = $new_rfree-1;
                $new_rpaid = $new_rpaid+1;
            }

            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_paid' => $new_lpaid,
                   'right_paid' => $new_rpaid,
                   'left_free' => $new_lfree,
                   'right_free' => $new_rfree,
                ]);
            $id =$posid;

        } else {
            break;
        }
    }
    return 0;
}






function treeeee($id ='', $uid=''){

    while($id!=""||$id!="0") {
        if(isMemberExists($id)){
            $posid=getParentId($id);
            if($posid=="0")
                break;
            if($posid==$uid){
                return true;
            }
            $id =$posid;
        } else {
            break;
        }
    }//while
    return 0;
}

function printBV($id){
    $cbv = MemberExtra::where('user_id', $id)->first();
    $rid = User::whereId($id)->first();
    $rnm = User::where('id', $rid->referrer_id)->first();
    echo "<b>Referred By:</b> $rnm->username <br>";
    echo "<b>Current BV:</b> L-$cbv->left_bv | R-$cbv->right_bv <br>";
}

function printBelowMember($id){
    $bmbr = MemberExtra::where('user_id', $id)->first() ;
    echo "<b>Paid Member Below:</b> L-$bmbr->left_paid | R-$bmbr->right_paid <br>";
    echo "<b>Free Member Below:</b> L-$bmbr->left_free | R-$bmbr->right_free <br>";
}

function updateMemberBelow($id='', $type=''){
    while($id!=""||$id!="0") {
        if(isMemberExists($id)) {
            $posid=getParentId($id);
            if($posid=="0")
                break;
            $position=getPositionParent($id);
            $currentCount = MemberExtra::where('user_id', $posid)->first() ;

            $new_lpaid = $currentCount->left_paid;
            $new_rpaid = $currentCount->right_paid;
            $new_lfree = $currentCount->left_free;
            $new_rfree = $currentCount->right_free;

            if($position=="L") {
                if($type=='FREE'){
                    $new_lfree = $new_lfree + 1;
                }else{
                    $new_lpaid = $new_lpaid+1;
                }
            }else {
                if($type=='FREE'){
                    $new_rfree = $new_rfree + 1;
                }else{
                    $new_rpaid = $new_rpaid+1;
                }
            }
            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_paid' => $new_lpaid,
                   'right_paid' => $new_rpaid,
                   'left_free' => $new_lfree,
                   'right_free' => $new_rfree,
                ]);
            $id =$posid;
        } else{
            break;
        }
    }
    return 0;
}

function getParentId($id){

    $count = User::whereId($id)->count() ;
    $posid = User::whereId($id)->first();
    if ($count == 1){
        return $posid->posid;
    }else{
        return 0;
    }
}


function getPositionParent($id){

    $count = User::whereId($id)->count();
    $position = User::whereId($id)->first() ;
    if ($count == 1){
        return $position->position;
    }else{
        return 0;
    }
}


function getLastChildOfLR($parentid ,$position){

    $childid = getTreeChildId($parentid, $position);

    if($childid!="-1"){
        $id = $childid;
    } else {
        $id = $parentid;
    }
    while($id!=""||$id!="0") {
        if(isMemberExists($id)) {
            $nextchildid = getTreeChildId($id, $position);
            if($nextchildid == "-1"){
                break;
            }else{
                $id = $nextchildid;
            }
        }else break;
    }
    return $id;
}
function getTreeChildId($parentid ,$position){
    $cou = User::where('posid', $parentid)->where('position', $position)->count();
    $cid = User::where('posid', $parentid)->where('position', $position)->first();
    if ($cou == 1){
        return $cid->id;
    }else{
        return -1;
    }
}

function isMemberExists($id){
    $count = User::where('id', $id)->count();
    if ($count == 1){
        return true;
    }else{
        return false;
    }
}

function Short_Text($data,$length){
    $first_part = explode(" ",$data);
    $main_part = strip_tags(implode(' ',array_splice($first_part,0, $length)));
    return $main_part ."...." ;
}

function ImageCheck($ext){
    if($ext != 'jpg' && $ext != 'jpeg' && $ext != 'png' && $ext != 'bnp'){
        $ext = "";
    }
    return $ext;
}

function NewFile($name, $data){
    $fh = fopen($name, "w");
    fwrite($fh,$data);
    fclose($fh);
}

function ViewFile($name){
    $fh = fopen($name, "r");
    $data = fread($fh,filesize($name));
    fclose($fh);
    return $data;
}

function Find_fist_int($string){
    preg_match_all('!\d+!', $string, $matches);
    if($matches[0] != ""){
        foreach($matches[0] as $key => $value){
            $url = $value;
            return $url;
            break;
        }
    }
}

function Replace($data) {
    $data = str_replace("'", "", $data);
    $data = str_replace("!", "", $data);
    $data = str_replace("@", "", $data);
    $data = str_replace("#", "", $data);
    $data = str_replace("$", "", $data);
    $data = str_replace("%", "", $data);
    $data = str_replace("^", "", $data);
    $data = str_replace("&", "", $data);
    $data = str_replace("*", "", $data);
    $data = str_replace("(", "", $data);
    $data = str_replace(")", "", $data);
    $data = str_replace("+", "", $data);
    $data = str_replace("=", "", $data);
    $data = str_replace(",", "", $data);
    $data = str_replace(":", "", $data);
    $data = str_replace(";", "", $data);
    $data = str_replace("|", "", $data);
    $data = str_replace("'", "", $data);
    $data = str_replace('"', "", $data);
    $data = str_replace("?", "", $data);
    $data = str_replace("  ", "_", $data);
    $data = str_replace("'", "", $data);
    $data = str_replace(".", "-", $data);
    $data = strtolower(str_replace("  ", "-", $data));
    $data = strtolower(str_replace(" ", "-", $data));
    $data = strtolower(str_replace(" ", "-", $data));
    $data = strtolower(str_replace("__", "-", $data));
    return str_replace("_", "-", $data);
}

其实,这本身就是另一个问题。helpers.php文件位于何处?它在应用程序文件夹下吗?它是如何包括在内的?从错误中可以看出php在当前名称空间下命名函数,所以我猜文件的包含/自动加载方式有问题吗?我的helpers.php文件位于app文件夹中,然后通过composer(在composer.json中)加载它。它看起来是这样的:

"autoload": {
    "files": [
        "app/helpers.php"
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "classmap": [
        "database/seeds",
        "database/factories"
    ]
},
如果更改该文件,则必须运行
composer dump autoload


…如果文件看起来已经是这样了,那么运行命令并没有什么坏处,因为可能出了问题。

感谢您的回答,我已经更新了问题,并包含了错误消息和我的mail.php文件。当用户试图在网站上注册时,会出现此错误。这意味着发送一封邮件进行验证。请帮忙澄清你的意思。谢谢你,你需要使用Laravel的邮件门面。。。因此,您可以通过在页面顶部添加“UseMail;”来导入该外观-好吗?然后将要发送的邮件放入相应的mail::to()。。。我也不明白你是从哪里发送的,从一个控制器发送的?是的,我猜它在调用一个控制器文件。我已经添加了几个文件,我猜它正在调用。请问我在哪里加上那行代码。如果可能,请编辑发送的代码,以协助修改,我将非常高兴。谢谢你的时间我更新了我的答案,也注意到我在片段中的评论。希望有帮助。谢谢。我现在就试试看。最后一件事,我可以使用我的cpanel创建的电子邮件帐户,对吗?这个答案也有帮助。后来我犯了一些错误,但这有助于解决这个问题
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=name@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
Mail::raw('your message', function ($message) use ($request) {

    $message->to('email@receiver.com');
    $message->from('youremail@sender.com');
    $message->subject("Email subject");
});
<?php
//edited
use App\General;
use App\User;
use App\MemberExtra;

function send_email($to, $subject, $name, $message){
        $general = General::first();
        
    if ($general->email_nfy == 1){
         $headers = "From: ".$general->web_title." <".$general->esender."> \r\n";
        $headers .= "Reply-To: ".$general->web_title." <".$general->esender."> \r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        
        $template = $general->emessage;
        $mm = str_replace("{{name}}",$name,$template);
        $message = str_replace("{{message}}",$message,$mm);
        //mail($to, $subject, $message, $headers);
        }else {
        return;
    }
}

function send_sms( $to, $message){
    $gnl = General::first();
    if($gnl->sms_nfy == 1) {
        $sendtext = urlencode("$message");
        $appi = $gnl->smsapi;
        $appi = str_replace("{{number}}",$to,$appi);
        $appi = str_replace("{{message}}",$sendtext,$appi);
        $result = file_get_contents($appi);
      }
      return;
}



function updateDepositBV($id, $deposit_amount)
{
    while($id !="" || $id != "0") {
        if(isMemberExists($id))
        {
            $posid = getParentId($id);
            if($posid == "0")
                break;
            $position = getPositionParent($id);
            $currentBV = MemberExtra::where('user_id', $posid)->first();

            if($position == "L"){
                $new_lbv = $currentBV->left_bv + $deposit_amount ;
                $new_rbv = $currentBV->right_bv;
            }else{
                $new_lbv = $currentBV->left_bv;
                $new_rbv = $currentBV->right_bv + $deposit_amount ;
            }

            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_bv' => $new_lbv,
                   'right_bv' => $new_rbv,
                ]);

            $id = $posid;

        } else {
            break;
        }

    }//while
    return 0;
}



function updatePaid($id){
    while($id!=""||$id!="0"){
        if(isMemberExists($id)) {
            $posid=getParentId($id);
            if($posid  == "0")
                break;
            $position = getPositionParent($id);

            $currentCount = MemberExtra::where('user_id',$posid )->first();

            $new_lpaid = $currentCount->left_paid;
            $new_rpaid = $currentCount->right_paid;
            $new_lfree = $currentCount->left_free;
            $new_rfree = $currentCount->right_free;

            if($position == "L") {
                $new_lfree = $new_lfree-1;
                $new_lpaid = $new_lpaid+1;
            }else {
                $new_rfree = $new_rfree-1;
                $new_rpaid = $new_rpaid+1;
            }

            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_paid' => $new_lpaid,
                   'right_paid' => $new_rpaid,
                   'left_free' => $new_lfree,
                   'right_free' => $new_rfree,
                ]);
            $id =$posid;

        } else {
            break;
        }
    }
    return 0;
}






function treeeee($id ='', $uid=''){

    while($id!=""||$id!="0") {
        if(isMemberExists($id)){
            $posid=getParentId($id);
            if($posid=="0")
                break;
            if($posid==$uid){
                return true;
            }
            $id =$posid;
        } else {
            break;
        }
    }//while
    return 0;
}

function printBV($id){
    $cbv = MemberExtra::where('user_id', $id)->first();
    $rid = User::whereId($id)->first();
    $rnm = User::where('id', $rid->referrer_id)->first();
    echo "<b>Referred By:</b> $rnm->username <br>";
    echo "<b>Current BV:</b> L-$cbv->left_bv | R-$cbv->right_bv <br>";
}

function printBelowMember($id){
    $bmbr = MemberExtra::where('user_id', $id)->first() ;
    echo "<b>Paid Member Below:</b> L-$bmbr->left_paid | R-$bmbr->right_paid <br>";
    echo "<b>Free Member Below:</b> L-$bmbr->left_free | R-$bmbr->right_free <br>";
}

function updateMemberBelow($id='', $type=''){
    while($id!=""||$id!="0") {
        if(isMemberExists($id)) {
            $posid=getParentId($id);
            if($posid=="0")
                break;
            $position=getPositionParent($id);
            $currentCount = MemberExtra::where('user_id', $posid)->first() ;

            $new_lpaid = $currentCount->left_paid;
            $new_rpaid = $currentCount->right_paid;
            $new_lfree = $currentCount->left_free;
            $new_rfree = $currentCount->right_free;

            if($position=="L") {
                if($type=='FREE'){
                    $new_lfree = $new_lfree + 1;
                }else{
                    $new_lpaid = $new_lpaid+1;
                }
            }else {
                if($type=='FREE'){
                    $new_rfree = $new_rfree + 1;
                }else{
                    $new_rpaid = $new_rpaid+1;
                }
            }
            MemberExtra::where('user_id', $posid)
                ->update([
                   'left_paid' => $new_lpaid,
                   'right_paid' => $new_rpaid,
                   'left_free' => $new_lfree,
                   'right_free' => $new_rfree,
                ]);
            $id =$posid;
        } else{
            break;
        }
    }
    return 0;
}

function getParentId($id){

    $count = User::whereId($id)->count() ;
    $posid = User::whereId($id)->first();
    if ($count == 1){
        return $posid->posid;
    }else{
        return 0;
    }
}


function getPositionParent($id){

    $count = User::whereId($id)->count();
    $position = User::whereId($id)->first() ;
    if ($count == 1){
        return $position->position;
    }else{
        return 0;
    }
}


function getLastChildOfLR($parentid ,$position){

    $childid = getTreeChildId($parentid, $position);

    if($childid!="-1"){
        $id = $childid;
    } else {
        $id = $parentid;
    }
    while($id!=""||$id!="0") {
        if(isMemberExists($id)) {
            $nextchildid = getTreeChildId($id, $position);
            if($nextchildid == "-1"){
                break;
            }else{
                $id = $nextchildid;
            }
        }else break;
    }
    return $id;
}
function getTreeChildId($parentid ,$position){
    $cou = User::where('posid', $parentid)->where('position', $position)->count();
    $cid = User::where('posid', $parentid)->where('position', $position)->first();
    if ($cou == 1){
        return $cid->id;
    }else{
        return -1;
    }
}

function isMemberExists($id){
    $count = User::where('id', $id)->count();
    if ($count == 1){
        return true;
    }else{
        return false;
    }
}

function Short_Text($data,$length){
    $first_part = explode(" ",$data);
    $main_part = strip_tags(implode(' ',array_splice($first_part,0, $length)));
    return $main_part ."...." ;
}

function ImageCheck($ext){
    if($ext != 'jpg' && $ext != 'jpeg' && $ext != 'png' && $ext != 'bnp'){
        $ext = "";
    }
    return $ext;
}

function NewFile($name, $data){
    $fh = fopen($name, "w");
    fwrite($fh,$data);
    fclose($fh);
}

function ViewFile($name){
    $fh = fopen($name, "r");
    $data = fread($fh,filesize($name));
    fclose($fh);
    return $data;
}

function Find_fist_int($string){
    preg_match_all('!\d+!', $string, $matches);
    if($matches[0] != ""){
        foreach($matches[0] as $key => $value){
            $url = $value;
            return $url;
            break;
        }
    }
}

function Replace($data) {
    $data = str_replace("'", "", $data);
    $data = str_replace("!", "", $data);
    $data = str_replace("@", "", $data);
    $data = str_replace("#", "", $data);
    $data = str_replace("$", "", $data);
    $data = str_replace("%", "", $data);
    $data = str_replace("^", "", $data);
    $data = str_replace("&", "", $data);
    $data = str_replace("*", "", $data);
    $data = str_replace("(", "", $data);
    $data = str_replace(")", "", $data);
    $data = str_replace("+", "", $data);
    $data = str_replace("=", "", $data);
    $data = str_replace(",", "", $data);
    $data = str_replace(":", "", $data);
    $data = str_replace(";", "", $data);
    $data = str_replace("|", "", $data);
    $data = str_replace("'", "", $data);
    $data = str_replace('"', "", $data);
    $data = str_replace("?", "", $data);
    $data = str_replace("  ", "_", $data);
    $data = str_replace("'", "", $data);
    $data = str_replace(".", "-", $data);
    $data = strtolower(str_replace("  ", "-", $data));
    $data = strtolower(str_replace(" ", "-", $data));
    $data = strtolower(str_replace(" ", "-", $data));
    $data = strtolower(str_replace("__", "-", $data));
    return str_replace("_", "-", $data);
}
"autoload": {
    "files": [
        "app/helpers.php"
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "classmap": [
        "database/seeds",
        "database/factories"
    ]
},