ParagonIE\GPGMailer\GPGMailer::encryptAndSign PHP Method

encryptAndSign() public method

Encrypt and sign the body of an email.
public encryptAndSign ( Message $message, string $fingerprint ) : Message
$message Message
$fingerprint string
return Message
    public function encryptAndSign(Message $message, string $fingerprint) : Message
    {
        if (!$this->serverKeyFingerprint) {
            throw new \Exception('No signing key provided');
        }
        $gnupg = new \Crypt_GPG($this->options);
        $gnupg->addEncryptKey($fingerprint);
        $gnupg->addSignKey($this->serverKeyFingerprint);
        // Replace the message with its encrypted counterpart
        $encrypted = $gnupg->encryptAndSign($message->getBodyText(), true);
        return $message->setBody($encrypted);
    }