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
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
class ConversationReplyMailer < ApplicationMailer
|
||||
include ConversationReplyMailerHelper
|
||||
default from: ENV.fetch('MAILER_SENDER_EMAIL', 'Chatwoot <accounts@chatwoot.com>')
|
||||
layout :choose_layout
|
||||
|
||||
@@ -12,16 +13,7 @@ class ConversationReplyMailer < ApplicationMailer
|
||||
new_messages = @conversation.messages.chat.where('id >= ?', last_queued_id)
|
||||
@messages = recap_messages + new_messages
|
||||
@messages = @messages.select(&:email_reply_summarizable?)
|
||||
mail({
|
||||
to: @contact&.email,
|
||||
from: from_email_with_name,
|
||||
reply_to: reply_email,
|
||||
subject: mail_subject,
|
||||
message_id: custom_message_id,
|
||||
in_reply_to: in_reply_to_email,
|
||||
cc: cc_bcc_emails[0],
|
||||
bcc: cc_bcc_emails[1]
|
||||
})
|
||||
prepare_mail(true)
|
||||
end
|
||||
|
||||
def reply_without_summary(conversation, last_queued_id)
|
||||
@@ -34,14 +26,7 @@ class ConversationReplyMailer < ApplicationMailer
|
||||
@messages = @messages.reject { |m| m.template? && !m.input_csat? }
|
||||
return false if @messages.count.zero?
|
||||
|
||||
mail({
|
||||
to: @contact&.email,
|
||||
from: from_email_with_name,
|
||||
reply_to: reply_email,
|
||||
subject: mail_subject,
|
||||
message_id: custom_message_id,
|
||||
in_reply_to: in_reply_to_email
|
||||
})
|
||||
prepare_mail(false)
|
||||
end
|
||||
|
||||
def email_reply(message)
|
||||
@@ -49,17 +34,7 @@ class ConversationReplyMailer < ApplicationMailer
|
||||
|
||||
init_conversation_attributes(message.conversation)
|
||||
@message = message
|
||||
|
||||
reply_mail_object = mail({
|
||||
to: @contact&.email,
|
||||
from: from_email_with_name,
|
||||
reply_to: reply_email,
|
||||
subject: mail_subject,
|
||||
message_id: custom_message_id,
|
||||
in_reply_to: in_reply_to_email,
|
||||
cc: cc_bcc_emails[0],
|
||||
bcc: cc_bcc_emails[1]
|
||||
})
|
||||
reply_mail_object = prepare_mail(true)
|
||||
|
||||
message.update(source_id: reply_mail_object.message_id)
|
||||
end
|
||||
@@ -86,6 +61,7 @@ class ConversationReplyMailer < ApplicationMailer
|
||||
@contact = @conversation.contact
|
||||
@agent = @conversation.assignee
|
||||
@inbox = @conversation.inbox
|
||||
@channel = @inbox.channel
|
||||
end
|
||||
|
||||
def should_use_conversation_email_address?
|
||||
|
||||
Reference in New Issue
Block a user