Files
eminuxandCursor 2db7504629
CI / scan_ruby (push) Failing after 12m56s
CI / scan_js (push) Successful in 12m23s
CI / lint (push) Failing after 12m15s
Aggiunge il rilevamento di invio e apertura delle email di campagna.
Ogni destinatario mostra se la mail è partita e se è stata aperta, con conteggi in dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-20 12:26:14 +02:00

44 lines
1.0 KiB
Ruby

class CampaignMailer < ApplicationMailer
layout false
def outreach(recipient, html:, subject:)
mailing = recipient.mailing
identity = mailing.mail_identity
html = Mailings::InlineImages.call(self, html)
html = wrap_html(html)
html = Mailings::OpenPixel.call(html, recipient)
mailing.files.each do |file|
attachments[file.filename.to_s] = {
mime_type: file.content_type,
content: file.download
}
end
mail(
from: identity.from_header,
to: recipient.email,
reply_to: identity.reply_to.presence,
subject: subject,
delivery_method_options: identity.smtp_settings
) do |format|
format.html { render html: html.html_safe }
end
end
private
def wrap_html(html)
return html if html.to_s.match?(/<html[\s>]/i)
<<~HTML
<!DOCTYPE html>
<html>
<body style="font-family: system-ui, sans-serif; line-height: 1.5; color: #18181b;">
#{html}
</body>
</html>
HTML
end
end