forwardemail.net icon indicating copy to clipboard operation
forwardemail.net copied to clipboard

[feat] Sample Documentation update for encrypt API

Open ianssoftcom opened this issue 11 months ago • 2 comments

Describe the feature

In the https://forwardemail.net/en/email-api#encrypt sample, it suggests

curl -X POST https://api.forwardemail.net/v1/encrypt \
  -d "[email protected]"

But when using regex matching for $1, it tries to use a shell variable expansion instead of as a literal $1. I would suggest using 'single quotes' instead - otherwise after a few minutes it bounces with an 'invalid "forward-email" TXT record due to an invalid regular expression email address match>'.

curl -X POST https://api.forwardemail.net/v1/encrypt -d 'input=/^(alias1|alias2)$/:[email protected]'

Checklist

  • [x] I have searched through GitHub issues for similar issues.
  • [x] I have completely read through the README and documentation.

ianssoftcom avatar Feb 03 '25 19:02 ianssoftcom

Trying to emulate a DL is still failing if I use a 2nd +$1 it bounces, maybe I'm doing it wrong?

curl -X POST https://api.forwardemail.net/v1/encrypt -d 'input=/^(alias1|alias2)$/:[email protected],/^(alias1|alias2)$/:[email protected]'

ianssoftcom avatar Feb 03 '25 20:02 ianssoftcom

Thanks @ianssoftcom on the docs update for double vs single quotes. Agree the shell expansion here is dangerous. For the 2nd address, I think you would need to encrypt each separately and then combine.

Encrypt user 1

curl -X POST https://api.forwardemail.net/v1/encrypt -d 'input=/^(alias1|alias2)$/:[email protected]'

Encrypt user 2

curl -X POST https://api.forwardemail.net/v1/encrypt -d 'input=/^(alias1|alias2)$/:[email protected]'

Combine the encrypted rules (will need to write a test for this)

"v=forward-email&<encrypted-output-A>,<encrypted-output-B>"

shaunwarman avatar Apr 26 '25 13:04 shaunwarman