1. Go to this page and download the library: Download vpsbg/laravel-pgp-mailer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vpsbg / laravel-pgp-mailer example snippets
use Vpsbg\PgpMailer\Models\PgpKey;
PgpKey::store('[email protected]', file_get_contents('alice.pub.asc'));
Mail::to('[email protected]')->send(new InvoiceMail($invoice));
// arrives as multipart/encrypted; only Alice's PGP client can read it
use Vpsbg\PgpMailer\Rules\ValidPgpKey;
$request->validate([
'pgp_key' => ['
$request->validate([
'email' => [' (new ValidPgpKey)->forEmail($request->input('email'))],
]);
use Vpsbg\PgpMailer\Models\PgpKey;
class User extends Authenticatable
{
public function pgpKey() { return $this->hasOne(PgpKey::class, 'email', 'email'); }
public function invoicePgpKey() { return $this->hasOne(PgpKey::class, 'email', 'invoice_email'); }
}
namespace App\Models;
class TenantPgpKey extends \Vpsbg\PgpMailer\Models\PgpKey
{
public function tenant() { return $this->belongsTo(Tenant::class); }
}
use Illuminate\Mail\Mailables\Headers;
public function headers(): Headers
{
return new Headers(text: ['X-Pgp-Mailer-Disable' => '1']);
// or: ['X-Pgp-Mailer-No-Encrypt' => '1']
}
use Vpsbg\PgpMailer\PgpMailer;
Mail::to($user)->send(PgpMailer::skip(new ThirdPartyNotification($data)));
Mail::to($user)->send(PgpMailer::unencrypted(new MonthlyDigestMail($data)));