i have a website that encrypts, and decrypts data that is entered to a text-box, when i click on "encrypt" the application will send an Email containing the encrypted message.
the problem : the email contains everything, EXCEPT the actual encrypted message.
i'm using mailtrap to view the sent emails. here's the code :
the controller:
public function encrypt(Request $request){
$output = encrypt($request->name);
Mail::to('kevin@example.com')->send(new EncryptionSent($output));
return view('decrypt', ['output' => $output,]);
}
The Mailables :
class EncryptionSent extends Mailable{
use Queueable, SerializesModels;
public $output;
public function __construct($output){
//
}
public function build(){
return $this->from('example@example.com')->view('decrypt', ['output' => $this->output]);
}
}
The View :
@extends ('home')
@section('content')
<div style = "width: 250px;border: 1px solid #000000;word-wrap:break-word">
<!-- The Decrypted code is located here -->
{{ $output }}
</div>
<form action="{{ url('/decrypt/'.$output)}}" method="POST" class="form- horizontal">
{{ csrf_field() }}
<br/><br/>
<button type="submit" class="btn btn-default">
<i class="fa fa-btn fa-plus"></i> Decrypt!
</button>
</form>
@endsection
i used dd() to find out the problem, but $output always returns the encrypted message in the controller and mailables.
thanks for reading, hoping that someone can help!
Don't use global . Use $output as parameter or as property of object ( $this->output ) And in the __construct method add $this->output = $output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.