mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:44:40 +08:00
DEV: Add SMTP group ID to EmailLog (#13381)
Adds a new `smtp_group_id` column to `EmailLog` which is filled in if the mail `from_address` matches a group's `email_username`. This is for easier debugging, so we know which emails have been sent via group SMTP.
This commit is contained in:
@ -97,6 +97,7 @@ module Email
|
||||
post_id = header_value('X-Discourse-Post-Id')
|
||||
topic_id = header_value('X-Discourse-Topic-Id')
|
||||
reply_key = set_reply_key(post_id, user_id)
|
||||
from_address = @message.from&.first
|
||||
|
||||
# always set a default Message ID from the host
|
||||
@message.header['Message-ID'] = "<#{SecureRandom.uuid}@#{host}>"
|
||||
@ -228,6 +229,12 @@ module Email
|
||||
|
||||
email_log.message_id = @message.message_id
|
||||
|
||||
# Log when a message is being sent from a group SMTP address, so we
|
||||
# can debug deliverability issues.
|
||||
if from_address && smtp_group_id = Group.where(email_username: from_address, smtp_enabled: true).pluck_first(:id)
|
||||
email_log.smtp_group_id = smtp_group_id
|
||||
end
|
||||
|
||||
DiscourseEvent.trigger(:before_email_send, @message, @email_type)
|
||||
|
||||
begin
|
||||
|
Reference in New Issue
Block a user