PHP

220 readers
1 users here now

founded 6 years ago
MODERATORS
1
 
 

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.
2
3
4
-4
Permanently Deleted (lemmings.world)
submitted 2 years ago* (last edited 2 years ago) by terusgormand8465@lemmings.world to c/php@lemmy.ml
 
 

Permanently Deleted

5
6
7
 
 

Link to internals discussion: https://externals.io/message/120972

8
 
 

A good article on implementing an event loop in PHP using the built-in fibers.

9
 
 

The article title is a little clickbaity, but basically, Doctrine and Symfony documentation don't mention that you can use constructor almost anywhere in the documentation.

10
 
 

A while ago I made this Symfony bundle that automagically memoizes your service methods using a PSR-6 cache.

Usage is very simple in 3 steps:

  1. have the service you want to memoize implement any interface
  2. mark the service with the #[Memoizable] attribute
  3. mark methods (or whole service) with the #[Memoize] attribute

Done!

11
1
submitted 2 years ago* (last edited 2 years ago) by rikudou@lemmings.world to c/php@lemmy.ml
12
 
 

Now you can go nuts with all the bots you can think of!

Any feedback welcome.

13
 
 

Now you can go nuts with all the bots you can think of!

Any feedback welcome.

14
 
 

There is a common misconception that large open source projects are well-funded. In practice, many rely on a small group of maintainers.

The PHP programming language is one of them. Despite being used by 75%+ of the web, PHP only has a few full-time contributors.

See https://dri.es/php-foundation-launched

#php #opensource

15
16
17
 
 

I'm looking at generating images on the fly in response to web requests. I've already created this in Go, but I want to compare it to PHP.

Specifically, I'm curious about two things - the tools available for creating images pixel-by-pixel, and the libraries/packages available for assembling images in more abstract ways, like with geometry helper methods.

18
19
1
25 Years of PHP History (www.jetbrains.com)
submitted 6 years ago by dignity@lemmy.ml to c/php@lemmy.ml
 
 

A Short History of PHP...