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

GMail Plain Text Wrapping #12

Closed
spib opened this issue Apr 9, 2023 · 3 comments
Closed

GMail Plain Text Wrapping #12

spib opened this issue Apr 9, 2023 · 3 comments

Comments

@spib
Copy link

spib commented Apr 9, 2023

Thanks for providing this library, it's excellent.

I wonder if you've ever seen an issue we're seeing where when we pass the plain-text email text to the library which has come from gmail, the lines are wrapped at 78 characters. This means that the cc list doesn't get parsed correctly and we end up with incomplete recipient lists. An example of how those emails look is shown below.

---------- Forwarded message ---------
From: Sender <sender@email.com>
Date: Fri, 25 Feb 2022 at 18:08
Subject: Test Email
To: Recipient <recipient@email.com>
Cc: Recipient 1 <recipient1@email.com>, Recipient 2 <
receipient2@email.com>, Recipient 3 <recipient3@email.com>


Email Start Here...
@eliottvincent
Copy link
Member

Hey there! I noticed a line break between line 6 and 7, which is not supposed to happen. How was the email originally parsed? Via mailparser?

I removed the line break:

---------- Forwarded message ---------
From: Sender <sender@email.com>
Date: Fri, 25 Feb 2022 at 18:08
Subject: Test Email
To: Recipient <recipient@email.com>
Cc: Recipient 1 <recipient1@email.com>, Recipient 2 <receipient2@email.com>, Recipient 3 <recipient3@email.com>


Email Start Here...

And the result is now ok:

{
  "forwarded": true,
  "message": null,
  "email": {
    "body": "Email Start Here...",
    "from": {
      "address": "sender@email.com",
      "name": "Sender"
    },
    "to": [
      {
        "address": "recipient@email.com",
        "name": "Recipient"
      }
    ],
    "cc": [
      {
        "address": "recipient1@email.com",
        "name": "Recipient 1"
      },
      {
        "address": "receipient2@email.com",
        "name": "Recipient 2"
      },
      {
        "address": "recipient3@email.com",
        "name": "Recipient 3"
      }
    ],
    "subject": "Test Email",
    "date": "Fri, 25 Feb 2022 at 18:08"
  }
}

@spib
Copy link
Author

spib commented Apr 10, 2023

Thanks for the super-quick reply. We're receiving the messages via SendGrid's Inbound Parse webhook (https://docs.sendgrid.com/for-developers/parsing-email/setting-up-the-inbound-parse-webhook#example-default-payload) and using the plain-text version of the email.

It does seem to be a known issue that GMail will wrap plain-text to 78 characters (https://fix.lazyjeff.com/2013/02/why-does-gmail-wrap-text-in-my-emails.html).

Are you guys using the html version of the email or plain text?

@eliottvincent
Copy link
Member

eliottvincent commented Apr 10, 2023

Ok, in that case my advise would be to use a dedicated parser like mailparser and give it the raw email. As a result you will get a clean, un-wrapped text representing the email.
Then you can pass that text to email-forward-parser.

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

No branches or pull requests

2 participants