[GH-ISSUE #5] New email to a soft deleted alias causes 'Integrity constraint violation: 1062 Duplicate entry' #616

Closed
opened 2026-03-14 09:47:43 +03:00 by kerem · 1 comment
Owner

Originally created by @vensko on GitHub (Nov 8, 2019).
Original GitHub issue: https://github.com/anonaddy/anonaddy/issues/5

github.com/anonaddy/anonaddy@2294f26926/app/Console/Commands/ReceiveEmail.php (L207)

If an alias was (soft) deleted and a new email arrives to it, it attempts to create the same alias again and causes the '1062 Duplicate entry' exception.

Originally created by @vensko on GitHub (Nov 8, 2019). Original GitHub issue: https://github.com/anonaddy/anonaddy/issues/5 https://github.com/anonaddy/anonaddy/blob/2294f26926e7227b9dd73463c1b82ba2c5654a9c/app/Console/Commands/ReceiveEmail.php#L207 If an alias was (soft) deleted and a new email arrives to it, it attempts to create the same alias again and causes the '1062 Duplicate entry' exception.
kerem closed this issue 2026-03-14 09:47:51 +03:00
Author
Owner

@anonaddy commented on GitHub (Nov 11, 2019):

Thanks for your comments.

This issue and #7 are both caused by the same issue. It is my fault for not mentioning this in the Self Hosting section of the readme file.

Before Postfix pipes an email to the application it does a database lookup to check if an alias has been deactivated or deleted. If the alias has been deactivated Postfix DISCARDS the email, if the alias has been deleted then Postfix REJECTS the email.

I've just updated the Postfix configuration of the readme to include instructions on how to set this up.

So because of this a deleted or deactivated alias will never be piped through to the application and the integrity constraint violation error will not be thrown.

If you would rather not use the above method you could pipe all emails through to the application and then write a simple function in ReceiveEmail.php to check if aliases have been deactivated/deleted.

<!-- gh-comment-id:552385163 --> @anonaddy commented on GitHub (Nov 11, 2019): Thanks for your comments. This issue and #7 are both caused by the same issue. It is my fault for not mentioning this in the Self Hosting section of the readme file. Before Postfix pipes an email to the application it does a database lookup to check if an alias has been deactivated or deleted. If the alias has been deactivated Postfix DISCARDS the email, if the alias has been deleted then Postfix REJECTS the email. I've just updated the [Postfix configuration](https://github.com/anonaddy/anonaddy#postfix-configuration) of the readme to include instructions on how to set this up. So because of this a deleted or deactivated alias will never be piped through to the application and the integrity constraint violation error will not be thrown. If you would rather not use the above method you could pipe all emails through to the application and then write a simple function in `ReceiveEmail.php` to check if aliases have been deactivated/deleted.
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#616
No description provided.