Class: Protege::ApplicationMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/protege/application_mailer.rb

Overview

Base mailer for the Protege engine and home of the Gateway's bounce notices.

Sits at the outbound edge of the Gateway. AgentMailbox returns these notices to Action Mailbox's bounce_with when an inbound email can't be accepted — no matching agent (#unrouted_bounce) or a sender rejected by the access guardrail (#access_denied_bounce). The sender is the host's app-wide default (+config.action_mailer.default_options+) when one is set, falling back to a deliberate placeholder — set the app-wide default so outbound mail originates from a domain the host actually controls.

Direct Known Subclasses

AlertMailer

Instance Method Summary collapse

Instance Method Details

#access_denied_bounce(inbound) ⇒ Mail::Message

Bounce an inbound email whose sender was rejected by the inbound access guardrail.

Returned to AgentMailbox#bounce_with_access_denied. Like #unrouted_bounce, the body is inline so rendering can't fail. The wording is deliberately neutral — it states the message was not accepted without disclosing the policy that rejected it.

Parameters:

  • inbound (::Mail::Message)

    the rejected inbound email

Returns:

  • (Mail::Message)

    the bounce notice addressed to the original sender



41
42
43
44
45
46
47
# File 'app/mailers/protege/application_mailer.rb', line 41

def access_denied_bounce(inbound)
  mail(
    to:      inbound.from,
    subject: 'Undeliverable: message rejected',
    body:    "Your message could not be delivered: this recipient is not accepting mail from you.\n"
  )
end

#attachment_rejected_bounce(inbound, reason:) ⇒ Mail::Message

Bounce an inbound email whose attachments breached the configured limits.

Returned to AgentMailbox#bounce_with_attachment_rejected. Like the other bounces, the body is inline so rendering can't fail. The reason (from Gateway::AttachmentPolicy) is included so the sender knows what to fix — it discloses only the limit, not anything sensitive.

Parameters:

  • inbound (::Mail::Message)

    the rejected inbound email

  • reason (String)

    the limit-breach reason from Gateway::AttachmentPolicy#violation

Returns:

  • (Mail::Message)

    the bounce notice addressed to the original sender



58
59
60
61
62
63
64
# File 'app/mailers/protege/application_mailer.rb', line 58

def attachment_rejected_bounce(inbound, reason:)
  mail(
    to:      inbound.from,
    subject: 'Undeliverable: attachment rejected',
    body:    "Your message could not be delivered: #{reason}.\n"
  )
end

#unrouted_bounce(inbound) ⇒ Mail::Message

Bounce an inbound email that matched no agent back to its sender.

Returned to AgentMailbox#bounce_with_unrouted, which hands it to Action Mailbox's bounce_with for delivery. The body is built inline (no template/layout) so a bounce can never fail to render.

Parameters:

  • inbound (::Mail::Message)

    the undeliverable inbound email

Returns:

  • (Mail::Message)

    the bounce notice addressed to the original sender



25
26
27
28
29
30
31
# File 'app/mailers/protege/application_mailer.rb', line 25

def unrouted_bounce(inbound)
  mail(
    to:      inbound.from,
    subject: 'Undeliverable: no such recipient',
    body:    "Your message could not be delivered: there is no agent at this address.\n"
  )
end