Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix not getting correct sender email address from forwarding email by Gmail rules #1044

Merged
merged 2 commits into from Aug 4, 2022

Conversation

sywhb
Copy link
Contributor

@sywhb sywhb commented Aug 4, 2022

Gmail will add some headers when forwarding emails by some rules:

  • X-Forwarded-To: recipient@omnivore.app
  • X-Forwarded-For: sender@omnivore.app recipient@omnivore.app
    and the from and to headers become the original sender and recipient's email addresses.

In this case, we are sending the original sender email address to Pub/Sub instead of the user's Omnivore account email address.
We fixed it by getting the Omnivore account email from the X-Forwarded-For header and sending it to Pub/Sub.

@vercel
Copy link

vercel bot commented Aug 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
omnivore-demo ✅ Ready (Inspect) Visit Preview Aug 4, 2022 at 1:30PM (UTC)
omnivore-prod ✅ Ready (Inspect) Visit Preview Aug 4, 2022 at 1:30PM (UTC)

// x-forwarded-for is a space separated list of email address
// the first one is the forwarding email sender and the last one is the recipient
// e.g. 'X-Forwarded-For: sender@omnivore.app recipient@omnivore.app
const forwardedFrom = headers['x-forwarded-for']?.toString().split(' ')[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is the key to the whole thing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have updated the description.
To sum up, the issue is Gmail changes the from to the original sender email address instead of the Omnivore account email address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants