[GH-ISSUE #566] Email forwarding fails after pgp key expired #970

Closed
opened 2026-03-14 11:19:54 +03:00 by kerem · 4 comments
Owner

Originally created by @pacroix on GitHub (Dec 3, 2023).
Original GitHub issue: https://github.com/anonaddy/anonaddy/issues/566

Version: v1.0.3 selfhosted

I recently started getting failed deliveries for one of my recipients with the only comment being to check the logs. After digging around a bit, I found out that the pgp key I'm using for this email had expired. I then renewed the key on my local machine, deleted the existing key in addy.io and uploaded it again.
However, forwarding to this recipient still does not work when encryption is enabled. Forwarding to other recipients, each using their own pgp key, works without a problem. I have also checked the server's key ring, but it contains the updated key.
I can't imagine, that I am the first person with an expired pgp key, but I don't know how else to renew the key without changing to a new one. And if not at least a more detailed error code would be nice to have.

Screenshot of the failed delivery tab. Another thing here: I can't download the email, even though I had the option enabled (or I'm looking in the wrong place)
failed_delivery

Supervisor log:

2023-12-03 22:03:26 App\Mail\ForwardEmail .......................... RUNNING
2023-12-03 22:03:26 App\Mail\ForwardEmail .................... 172.61ms FAIL
2023-12-03 22:12:17 App\Notifications\FailedDeliveryNotification ... RUNNING
2023-12-03 22:12:17 App\Notifications\FailedDeliveryNotification  81.57ms FAIL

Laravel log:

[2023-12-03 22:03:26] production.ERROR: encrypt-sign failed {"exception":"[object] (Exception(code: 0): encrypt-sign failed at /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php:248)
[stacktrace]
#0 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(248): gnupg->encryptsign()
#1 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(151): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->pgpEncryptAndSignString()
#2 /var/www/anonaddy/app/CustomMailDriver/CustomMailer.php(80): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->encrypt()
#3 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(205): App\\CustomMailDriver\\CustomMailer->send()
#4 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\\Mail\\Mailable->Illuminate\\Mail\\{closure}()
#5 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(198): Illuminate\\Mail\\Mailable->withLocale()
Originally created by @pacroix on GitHub (Dec 3, 2023). Original GitHub issue: https://github.com/anonaddy/anonaddy/issues/566 Version: v1.0.3 `selfhosted` I recently started getting failed deliveries for one of my recipients with the only comment being to check the logs. After digging around a bit, I found out that the pgp key I'm using for this email had expired. I then renewed the key on my local machine, deleted the existing key in addy.io and uploaded it again. However, forwarding to this recipient still does not work when encryption is enabled. Forwarding to other recipients, each using their own pgp key, works without a problem. I have also checked the server's key ring, but it contains the updated key. I can't imagine, that I am the first person with an expired pgp key, but I don't know how else to renew the key without changing to a new one. And if not at least a more detailed error code would be nice to have. Screenshot of the failed delivery tab. Another thing here: I can't download the email, even though I had the option enabled (or I'm looking in the wrong place) ![failed_delivery](https://github.com/anonaddy/anonaddy/assets/18500368/7906d369-598b-4135-9c85-9dcd0bf4e3f3) Supervisor log: ``` 2023-12-03 22:03:26 App\Mail\ForwardEmail .......................... RUNNING 2023-12-03 22:03:26 App\Mail\ForwardEmail .................... 172.61ms FAIL 2023-12-03 22:12:17 App\Notifications\FailedDeliveryNotification ... RUNNING 2023-12-03 22:12:17 App\Notifications\FailedDeliveryNotification 81.57ms FAIL ``` Laravel log: ``` [2023-12-03 22:03:26] production.ERROR: encrypt-sign failed {"exception":"[object] (Exception(code: 0): encrypt-sign failed at /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php:248) [stacktrace] #0 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(248): gnupg->encryptsign() #1 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(151): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->pgpEncryptAndSignString() #2 /var/www/anonaddy/app/CustomMailDriver/CustomMailer.php(80): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->encrypt() #3 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(205): App\\CustomMailDriver\\CustomMailer->send() #4 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\\Mail\\Mailable->Illuminate\\Mail\\{closure}() #5 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(198): Illuminate\\Mail\\Mailable->withLocale() ```
kerem closed this issue 2026-03-14 11:19:59 +03:00
Author
Owner

@willbrowningme commented on GitHub (Dec 5, 2023):

Thanks, I've just pushed a fix for this by moving it within the try/catch block.

<!-- gh-comment-id:1840537412 --> @willbrowningme commented on GitHub (Dec 5, 2023): Thanks, I've just pushed a fix for this by moving it within the try/catch block.
Author
Owner

@pacroix commented on GitHub (Dec 5, 2023):

Thank you for looking into this, but the error is still occurring and unfortunately there is still no more meaningful error message, apart from the message to check the logs.

[2023-12-05 23:15:06] production.ERROR: encrypt-sign failed {"exception":"[object] (Exception(code: 0): encrypt-sign failed at /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php:248)
[stacktrace]
#0 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(248): gnupg->encryptsign()
#1 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(151): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->pgpEncryptAndSignString()
#2 /var/www/anonaddy/app/CustomMailDriver/CustomMailer.php(71): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->encrypt()
#3 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(66): App\\CustomMailDriver\\CustomMailer->send()
#4 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): Illuminate\\Notifications\\Channels\\MailChannel->send()
#5 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\\Notifications\\NotificationSender->sendToNotifiable()
#6 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\\Notifications\\NotificationSender->Illuminate\\Notifications\\{closure}()
#7 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(101): Illuminate\\Notifications\\NotificationSender->withLocale()
#8 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(54): Illuminate\\Notifications\\NotificationSender->sendNow()

<!-- gh-comment-id:1841790834 --> @pacroix commented on GitHub (Dec 5, 2023): Thank you for looking into this, but the error is still occurring and unfortunately there is still no more meaningful error message, apart from the message to check the logs. ``` [2023-12-05 23:15:06] production.ERROR: encrypt-sign failed {"exception":"[object] (Exception(code: 0): encrypt-sign failed at /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php:248) [stacktrace] #0 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(248): gnupg->encryptsign() #1 /var/www/anonaddy/app/CustomMailDriver/Mime/Crypto/OpenPGPEncrypter.php(151): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->pgpEncryptAndSignString() #2 /var/www/anonaddy/app/CustomMailDriver/CustomMailer.php(71): App\\CustomMailDriver\\Mime\\Crypto\\OpenPGPEncrypter->encrypt() #3 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(66): App\\CustomMailDriver\\CustomMailer->send() #4 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): Illuminate\\Notifications\\Channels\\MailChannel->send() #5 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\\Notifications\\NotificationSender->sendToNotifiable() #6 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\\Notifications\\NotificationSender->Illuminate\\Notifications\\{closure}() #7 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(101): Illuminate\\Notifications\\NotificationSender->withLocale() #8 /var/www/anonaddy/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(54): Illuminate\\Notifications\\NotificationSender->sendNow() ```
Author
Owner

@willbrowningme commented on GitHub (Dec 6, 2023):

Did the email still get forwarded but with encryption turned off?

Did you receive a GPG key expired email notification and was encryption disabled for that recipient when viewing from the recipients page?

<!-- gh-comment-id:1842582256 --> @willbrowningme commented on GitHub (Dec 6, 2023): Did the email still get forwarded but with encryption turned off? Did you receive a GPG key expired email notification and was encryption disabled for that recipient when viewing from the recipients page?
Author
Owner

@willbrowningme commented on GitHub (Dec 6, 2023):

I've just fixed it in this commit, I was only catching RuntimeException and not Exception which is why it wasn't working as expected.

<!-- gh-comment-id:1842840641 --> @willbrowningme commented on GitHub (Dec 6, 2023): I've just fixed it in [this commit](https://github.com/anonaddy/anonaddy/commit/dc88b9bcd25f8a4f5f394bb51b03473ca338bea0), I was only catching `RuntimeException` and not `Exception` which is why it wasn't working as expected.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/anonaddy#970
No description provided.