Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

remigis's avatar

The Process class relies on proc_open, which is not available on your PHP installation.

The Process class relies on proc_open, which is not available on your PHP installation.

public function action($id, $action){
        if($action == "confirm"){
            return $this->confirm($id);
        }
        if($action == "ignore"){
            return $this->ignore($id);
        }
        
        return redirect()->back()->with('errors', ["This action not available"]);
    }
    
    public function confirm($id){
        $invitation = $this->getData($id);
        Mail::to($invitation->getEmail())->send(new RegistrationLink($invitation->getLink()));
        $invitation->sent = 1;
        $invitation->save();
        return redirect()->back()->with('success', ['Email with registration link sent successfully.']);
    }
    
    public function ignore($id){
        $invitation = $this->getData($id);
        Mail::to($invitation->getEmail())->send(new RegistrationLinkDeclined());
        $invitation->delete();
        return redirect()->back()->with('success', ['Registration request declined and deleted.']);
    }
    
    public function getData($id){
        try {
            $invitation = Invitation::where('id', $id)->firstOrFail();
        } catch (ModelNotFoundException $e) {
            return redirect()->back()->with('errors', ['This invitation request do not exist']);
        }
        
        if($invitation->sent != 0){
            return redirect()->back()->with('errors', ['Invitation already sent']);
        }
              
        return $invitation;
    }

When i run same code in localhost I get this: https://ibb.co/dG1gGR8

Don't know if problem is in this code. But i think there is something wrong with mailing.

0 likes
7 replies
Sti3bas's avatar

What is set for MAIL_DRIVER in .env file?

Sti3bas's avatar

@remigis are you on shared hosting? Seems like your hosting doesn't support proc_open function.

remigis's avatar

yes it do not support proc_open. so now i do this.

public function action($id, $action){
        if($action == "confirm"){
            return $this->confirm($id);
        }
        if($action == "ignore"){
            return $this->ignore($id);
        }
        
        return redirect()->back()->with('errors', ["This action not available"]);
    }
    
    public function confirm($id){
        $invitation = $this->getData($id);
        $headers = "From: TeamWorx <[email protected]>\r\n";
        $headers .= "CC: ".$invitation->getEmail()."\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        mail($invitation->getEmail(), "Registration Link", view('emails.registration', ['url' => $invitation->getLink()])->render(), $headers);
        $invitation->sent = 1;
        $invitation->save();
        return redirect()->back()->with('success', ['Email with registration link sent successfully.']);
    }
    
    public function ignore($id){
        $invitation = $this->getData($id);
        $headers = "From: TeamWorx <[email protected]>\r\n";
        $headers .= "CC: ".$invitation->getEmail()."\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        mail($invitation->getEmail(), "Registration Declined", view('emails.registrationDeclined')->render(), $headers);
        $invitation->delete();
        return redirect()->back()->with('success', ['Registration request declined and deleted.']);
    }
    
    public function getData($id){
        try {
            $invitation = Invitation::where('id', $id)->firstOrFail();
        } catch (ModelNotFoundException $e) {
            return redirect()->back()->with('errors', ['This invitation request do not exist']);
        }
        
        if($invitation->sent != 0){
            return redirect()->back()->with('errors', ['Invitation already sent']);
        }
              
        return $invitation;
    }

When action is "Confirm" for the first time its all ok.

https://ibb.co/F445KWt

But if hit confirm second time it triggers this part

 if($invitation->sent != 0){
            return redirect()->back()->with('errors', ['Invitation already sent']);
        }

and i get this https://ibb.co/M6r59DN again

but when i press back in browser and refresh the page Invitation already sent error is displayed

https://ibb.co/z8JbVFr

Sti3bas's avatar

@remigis first of all, instead of using mail function you can use smtp mail driver. Don't forget to fill the settings in the .env file. This will solve your original issue.

The second issue seems to be related to redirect()->back(). Do you tried to redirect to the exact route instead of using back()?

remigis's avatar

Changed it to

 return redirect()->route('showInvitations')->with('errors', ['Invitation already sent']);

Same result.

Please or to participate in this conversation.