PHP

cross-posted from: https://lemmy.world/post/48266338

I am learning how to use Symfony Mailer and am a bit lost on the encrypting message section.

This is my simple code below which works in sending the email.

<?php

require 'vendor/autoload.php';

const FROM = 'me@example.com';

const TO = 'example@email.com';

const SUBJECT = 'My Subject';

const MESSAGE = 'Hello World';

const DSN = 'smtp://localhost:1025';

$transport = \Symfony\Component\Mailer\Transport::fromDsn(DSN);

$mailer = new \Symfony\Component\Mailer\Mailer($transport);

$email = (new \Symfony\Component\Mime\Email())
    ->from(FROM)
    ->to(TO)
    ->subject(SUBJECT)
    ->text(MESSAGE);

$encrypter = new \Symfony\Component\Mime\Crypto\SMimeEncrypter('my-certificate.crt');
$encryptedEmail = $encrypter->encrypt($email);

try {
    $mailer->send($encryptedEmail);
} catch (\Symfony\Component\Mailer\Exception\TransportExceptionInterface $error) {
    echo 'Unable to send email' . PHP_EOL;
}

And this is how I generated the certificate and key...

openssl genrsa -aes256 -out my-certificate.key 4096
openssl req -new -x509 -days 29220 -key my-certificate.key -out my-certificate.crt

I am able to receive the email using SMTP tools like Mailpit.

My two questions are...

  1. My emails are encrypted using the certificate, but shouldn't it be done using PGP?
  2. How do I decrypt the email with SMTP testing tool or any online or CLI tool? I tried to decrypt the email and could not decrypt it even though I have all of the keys.

Perfex CRM <=3.4.0 allows unauthenticated RCE via insecure deserialization

2mon 28d ago by lemmy.world/u/monica_b1998 in php@lemmy.ml from nullcathedral.com
102

Introducing Safe and Progressive Strict Type Adoption Rule

4mon 3d ago by lemmy.world/u/monica_b1998 in php@lemmy.ml from getrector.com
403

Permanently Deleted

1y 7mon ago by lemmings.world/u/terusgormand8465 in php@lemmy.ml
-304

Who is behind PHP - a little on the process of making PHP

2y 9mon ago by lemmings.world/u/rikudou in php@lemmy.ml from christoph-rumpel.com
305

Benefits of separating core code from infrastructure code

2y 9mon ago by lemmings.world/u/rikudou in php@lemmy.ml from dev.to
106

RFC: DOM HTML5 parsing and serialization

2y 9mon ago by lemmings.world/u/rikudou in php@lemmy.ml from wiki.php.net
307

Event loop using Fibers

2y 9mon ago by lemmings.world/u/rikudou in php@lemmy.ml from aoeex.com
108

Using constructors with Doctrine entities

2y 10mon ago by lemmings.world/u/rikudou in php@lemmy.ml from withinboredom.info
109

Memoization bundle for Symfony

2y 10mon ago by lemmings.world/u/rikudou in php@lemmy.ml from github.com
2010

Consume Symfony messenger messages in Go

2y 10mon ago by lemmings.world/u/rikudou in php@lemmy.ml from rherault.dev
1011

Package to work with Lemmy API

2y 11mon ago by lemmings.world/u/rikudou in php@lemmy.ml from packagist.org
1012

Package to work with Lemmy API

2y 11mon ago by lemmings.world/u/rikudou in php@lemmy.ml from packagist.org
1013

PHP Foundation launched

4y 6mon ago by lemmy.ml/u/danie10 in php@lemmy.ml from dri.es
1014

PHP's Git Server Compromised, Now Switching To GitHub

5y 2mon ago by lemmy.ml/u/strubbl in php@lemmy.ml from www.phoronix.com
1015

The Definitive PHP 5.6, 7.0, 7.1, 7.2, 7.3, and 7.4 Benchmarks (2020)

5y 5mon ago by lemmy.ml/u/Rumblestiltskin in php@lemmy.ml from kinsta.com
1016

Can anyone point me towards some resources for image generation?

5y 11mon ago by lemmy.ml/u/imperator in php@lemmy.ml
1017

PHP-Дайджест № 182 (1 – 22 июня 2020)

5y 11mon ago by lemmy.ml/u/dignity in php@lemmy.ml from habr.com
1018

25 Years of PHP History

5y 11mon ago by lemmy.ml/u/dignity in php@lemmy.ml from www.jetbrains.com
1019