Commit Graph

48 Commits

Author SHA1 Message Date
Sojan Jose
515778eabb chore: Disable throwing error for malformed to address (#10464)
We don't need to raise error on sentry for malformed to address as it is already logged.

Fixes: https://linear.app/chatwoot/issue/CW-3151/standarderror-invalid-email-to-address-header-standarderror
2024-11-20 18:58:54 -08:00
Sojan Jose
933ae8aa49 fix: Email attachments created with empty filename (#10420)
- We observed in prod for certain emails active storage blob objects
were getting created with empty file name. The conversations further
causes conversation and filter pages to break. This change will fix the
mentioned issue.

fixes:
https://linear.app/chatwoot/issue/CW-3331/missing-file-name-for-some-of-the-uploads-for-emails

---------

Co-authored-by: Pranav <pranavrajs@gmail.com>
2024-11-15 09:07:24 +04:00
Pranav
8cdbdaaa07 fix: Process attachments as regular attachments if the text/plain or text/html part is empty (#10379)
Some email clients automatically set Content-Disposition to inline for
specific content types, such as images. In cases where the email body is
empty, inline attachments may not display correctly due to our previous
implementation. Our assumption was that these attachments are referenced
within text/plain or text/html parts.

Customer-reported issues, especially with Apple Mail, show emails with
attachments marked as inline but without any corresponding text parts.
This leads to missing attachments even though would have processed the
attachment.

This update introduces a check for the presence of a text part. If none
exists, inline attachments are treated as regular attachments and added
to the external attachments array, ensuring that all attachments display
properly.

<details>
<summary><b>Script to update the existing emails that are already
available in the system</b></summary>

```rb
def update_content id
  message = Message.find id
  conversation = message.conversation
  message_id = message.source_id

  channel = message.inbox.channel

  authentication_type = 'XOAUTH2'
  imap_password = Google::RefreshOauthTokenService.new(channel: channel).access_token
  imap = Net::IMAP.new(channel.imap_address, port: channel.imap_port, ssl: true)
  imap.authenticate(authentication_type, channel.imap_login, imap_password)
  imap.select('INBOX')

  results = imap.search(['HEADER', 'MESSAGE-ID', message_id])
  message_content = imap.fetch(results.first, 'RFC822').first.attr['RFC822']
  mail = MailPresenter.new(Mail.read_from_string(message_content))

  mail_content = if mail.text_content.present?
                   mail.text_content[:reply]
                 elsif mail.html_content.present?
                   mail.html_content[:reply]
                 end

  attachments = mail.attachments.last(Message::NUMBER_OF_PERMITTED_ATTACHMENTS)
  inline_attachments = attachments.select { |attachment| attachment[:original].inline? && mail_content.present? }
  regular_attachments = attachments - inline_attachments

  regular_attachments.each do |mail_attachment|
    attachment = message.attachments.new(
      account_id: conversation.account_id,
      file_type: 'file'
    )
    attachment.file.attach(mail_attachment[:blob])
  end

  message.save!
end
```
</details>
2024-11-04 10:25:01 +01:00
Sojan Jose
7968e98529 chore: Stop processing auto-response emails (#9606)
Stop processing auto-response emails
https://www.notion.so/chatwoot/Avoid-Auto-Replies-sorcerer-s-apprentice-mode-55ffb09efbd7451994f1ff852de4c168?pvs=4
2024-06-13 14:19:11 -07:00
Sojan Jose
4284c123a6 chore: Handle invalid email address in IMAP channel (#9450) 2024-05-10 08:55:26 +05:30
Shivam Mishra
c62c512ec4 fix: inline attachments not handled if tag was missing (#9068) 2024-03-06 17:15:29 +05:30
Vishnu Narayanan
d53097f77d fix: Raise error if email to_header is invalid (#8688) 2024-02-20 17:03:39 -08:00
Pranav Raj S
eb379e1849 fix(refactor): Cleanup the specs and the logic for FetchIMAP job (#8766) 2024-02-10 14:03:50 -08:00
Shivam Mishra
834c219b9b feat(perf): update query to do a simpler search [CW-2997] (#8763)
Message search would frequently timeout. The reason was that the query would join the conversation too, the new query searches the message table directly

Co-authored-by: Sojan <sojan@pepalo.com>
2024-01-23 14:20:00 +04:00
Sojan Jose
aaf4fee9a6 chore: Fix sentry errors in email processing for bounce notifications (#8677)
This case occurs for bounce notification emails where the from address is From: "" (Mail Delivery System) . We will be discarding these emails for now.

Fixes: https://linear.app/chatwoot/issue/CW-2793/activerecordrecordinvalid-validation-failed-email-invalid-email
2024-01-10 14:30:23 -08:00
Shivam Mishra
e529e1206e fix: Update inline image processing logic to fix missing images when multiple inline images present (#7861) 2023-09-06 14:35:19 +05:30
Pranav Raj S
6ddc99d066 fix: Update the in_reply_to to logic to use processed_mail (#7793) 2023-08-24 16:19:17 +05:30
Tejaswini Chile
c99d9f9557 fix: search for nil in-reply-to messages (#7286) 2023-06-12 16:01:56 +05:30
Tejaswini Chile
f64f2138db fix: Update mail check for html_part (#7273) 2023-06-09 16:08:40 +05:30
Tejaswini Chile
aae6081d73 fix: check content disposition, for inline messages in mail (#7231) 2023-06-05 20:28:32 +05:30
Tejaswini Chile
09971fd613 fix: Wrap references string into array (#7243) 2023-06-03 07:33:36 +05:30
Tejaswini Chile
abc27fa791 fix: find mail message by references (#7220) 2023-05-31 19:23:29 +05:30
Sojan Jose
7ab7bac6bf chore: Enable the new Rubocop rules (#7122)
fixes: https://linear.app/chatwoot/issue/CW-1574/renable-the-disabled-rubocop-rules
2023-05-19 14:37:10 +05:30
Sojan Jose
022383d942 chore: Upgrade to Rails 7 (#6719)
fixes: #6736
2023-05-06 10:44:52 +05:30
Sojan Jose
12cd15b6ad chore: Disable email processing for suspended accounts (#5762)
- Disable email processing for suspended accounts
2022-10-26 03:40:47 -07:00
Jordan Brough
1bdd59f025 Find by downcased email in SupportMailbox (#5211) 2022-10-12 13:38:18 +05:30
Jordan Brough
59b31615ed chore: Use "create!" and "save!" bang methods when not checking the result (#5358)
* Use "create!" when not checking for errors on the result
* Use "save!" when not checking the result
2022-09-13 17:40:06 +05:30
Sojan Jose
4187428729 chore: Update dependencies to the latest versions (#5033) 2022-07-15 09:51:59 +07:00
Tejaswini Chile
97bf5d0c6a fix: Fetch email address to create contact (#4952)
Get the email address from the email content in the correct format.

Fixes: chatwoot/product#454
2022-07-02 17:40:28 +05:30
Aswin Dev P.S
31cdc63e18 fix: Remove IMAP and SMTP email validation (#4435)
* Remove IMAP and SMTP email validation
* Rename imap_email & smtp_email columns to imap_login & smtp_login respectively.
* Use channel email domain if inbound email domain not present
2022-04-11 07:07:20 -07:00
Tejaswini Chile
57359be37e Fix: Find mailbox with cc email (#4372) 2022-04-08 11:20:19 +05:30
Tejaswini Chile
5be9380547 Fix: html mail fix with html_body content (#4011) 2022-03-30 18:04:30 +05:30
Pranav Raj S
505c93c467 revert: "fix: html content is available and mail_part empty" (#3986)
Reverts de4e4c6
2022-02-15 17:19:28 +05:30
Tejaswini Chile
d5c9193d1a feat: Add specs for reply-to changes (#3959) 2022-02-15 10:28:04 +05:30
Tejaswini Chile
de4e4c6f65 fix: html content is available and mail_part empty (#3964) 2022-02-14 20:22:58 +05:30
Tejaswini Chile
e997aaceb7 Fix: Email Parsing for html fix (#3659) 2022-01-20 15:55:35 -08:00
Sojan Jose
13d6734977 chore: Minor API cleanups (#3645)
- exception list updated
- revert mail presenter changes
2021-12-23 00:55:49 +05:30
Tejaswini Chile
44486fc8e1 chore: Improve email parsing using email trimmer gem (#3611)
Email parsing using email_trimmer gem

Fixes: #3539 , #2954, #3572
2021-12-22 18:16:40 +05:30
Tejaswini Chile
c2519ea1ea Fix: fixing mail to and in_reply_to issues (#3451) 2021-12-10 19:42:26 +05:30
Aswin Dev P.S
24e6a92297 feat: IMAP Email Channel (#3298)
This change allows the user to configure both IMAP and SMTP for an email inbox. IMAP enables the user to see emails in Chatwoot. And user can use SMTP to reply to an email conversation.

Users can use the default settings to send and receive emails for email inboxes if both IMAP and SMTP are disabled.

Fixes #2520
2021-11-19 11:52:27 +05:30
Sojan Jose
acb06e7df6 chore: Prevent notification email loop (#3386)
Configuring an agent email also as a support email inbox leads to conversations getting created in a loop if notifications were also configured to the same email.
2021-11-15 19:15:51 +05:30
Tejaswini Chile
6998e9aa2d fix: Update email message_id parsing order (#3073)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-10-12 20:46:00 +05:30
Tejaswini Chile
6ad5a7452c fix: Emails not delivered when case does not match
Fixes #2504
2021-09-17 22:14:39 +05:30
Tejaswini Chile
a0ffefad71 chore: Use the name of the sender from the mail object
if the sender email is Sony Mathew <Sony@chatwoot.com> Contact should be built with Sony Mathew

Fixes #2911
2021-09-16 13:26:52 +05:30
Tejaswini Chile
09e3413d10 chore: consider X-original-sender to create contact in case of group mail (#2841)
For emails forwarded from google groups, Google rewrites the FROM address to the group email and the original email will be available under X-Original-Sender. This PR enables chatwoot to handle this case.

Fixes: #2715
2021-08-24 14:18:08 +05:30
Pranav Raj S
bdc4ecffc1 fix: Save content_type, multipart information to email message model (#2774) 2021-08-09 18:04:34 +05:30
Sojan Jose
ca4a766b82 chore: Enable email channel (#1851) 2021-03-04 13:59:59 +05:30
Sony Mathew
f9b0427751 feat: email channel backend (#140) (#1255)
* feat: added support mailbox to handle email channel (#140)

Added a new mailbox called 'SupportMailbox' to handle all the
incoming emails other than reply emails.

An email channel will have a support email and forward email
associated with it. So we filter for the right email inbox based on
the support email of that inbox and route this to this mailbox.

This mailbox finds the account, inbox, contact (create a new one
if it does not exist) and creates a conversation and adds the
email content as the first message in the conversation.

Other minor things handled in this commit:

* renamed the procs for routing emails in application mailbox
* renamed ConversationMailbox to ReplyMailbox
* Added a fallback content in MailPresenter
* Added a record saving (bang) versions of enabling and disabling
features in Featurable module
* added new factory for the email channel

refs: #140
2020-09-21 22:44:22 +05:30
Sojan Jose
31c07771e8 feat: Notification on new messages in conversation (#1204)
fixes: #895
fixes: #1118
fixes: #1075

Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
2020-09-10 19:19:15 +05:30
Sojan Jose
ac5d755545 chore: Update dependencies (#1173) 2020-09-08 11:24:08 +05:30
Sojan Jose
432dad203b Feature: Inbox greeting message (#927)
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
2020-06-09 23:54:35 +05:30
Sony Mathew
11b4b4ea3f Chore: Parse quoted text in incoming emails (#883) (#884)
* Chore: Parse quoted text in incoming emails (#883)
* Parsed the quoted text and replies in incoming emails and store them separately
* Did this parsing for plain text and html part of emails
* In the chat window, we will only show the parsed reply alone

* Conversation mailbox test fixes (#883)
2020-05-22 18:07:06 +05:30
Sony Mathew
0b65526b85 Feature: Conversation Continuity with Email (#770)
* Added POC for mail inbox reply email
* created mailbox and migratuion for the same
* cleaned up sidekiq queues and added the queues for action mailbox and active storage
* created conversation mailbox and functionlaity to create a message on the conversation when it's replied

* Added UUID to conversation to be used in email replies

* added migration to add uuid for conversation
* changed parsing and resource fetching to reflect matching uuid and
  loading conversation alone
* cleaned up conversation mailbox.rb

* Added content type & attribute for message

* Added the new reply email to outgoing emails
* Added migration to accounts for adding domain and settings
* Modified seeds to reflect this changes
* Added the flag based column on account for boolean settings
* Added the new reply to email in outgoing conversation emails based on conditions

* Added dynamic email routing in application mailbox
* Added dynamic email routing in application mailbox
* Added a catch all deafult empty mailbox
* Added annotation for account

* Added the complete email details & attachments to the message
* Added the complete email details to the message in content_attributes, like subject, to, cc, bcc etc
* Modified the mail extractor to give a serilaized version of email
* Handled storing attachments of email on the message

* Added incoming email settings, env variables

* [#138] Added documentation regarding different email settings and variables

* Fixed the mail attachments blob issue (#138)
* Decoided attachments were strings and had to construct blobs out fo them to work with active storage
* Fixed the content encoding issue with mail body
* Fixed issue with Proc used in apllication mailbox routing
* Fixed couple of typos and silly mistakes

* Set appropriate from email for conversation reply mails (#138)
* From email was taken from a env variable, changed it to take from account settings if enabled
* Set the reply to email correctly based on conversation UUID
* Added commented config ind development.rb for mailbox ingress

* Added account settings for domain and support email (#138)
* Added the new attributes in accounts controller params whitelisting, api responses
* Added options for the the new fields in account settings

* Fixed typos in email continuity docs and warnings

* Added specs for conversation reply mailer changes (#138)
* Added specs for
  * conversation reply mailer
  * Accounts controller
  * Account and Conversation models

* Added tests for email presenter (#138)

* Specs for inbound email routing and mailboxes (#138)
2020-04-30 20:20:26 +05:30