Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
class CampaignMailer < ApplicationMailer
|
||||
layout false
|
||||
|
||||
def outreach(recipient, html:, subject:)
|
||||
mailing = recipient.mailing
|
||||
identity = mailing.mail_identity
|
||||
html = Mailings::InlineImages.call(self, html)
|
||||
|
||||
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: wrap_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
|
||||
Reference in New Issue
Block a user