From c4639b77378675f16c28660f43a23f2805ee6392 Mon Sep 17 00:00:00 2001 From: MQuy Date: Wed, 30 Nov 2016 21:54:44 +0800 Subject: allow context type when set body mail --- actionmailer/lib/action_mailer/base.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 1f5738bbab..2cb5c5514d 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -900,15 +900,19 @@ module ActionMailer yield(collector) collector.responses elsif headers[:body] - [{ - body: headers.delete(:body), - content_type: self.class.default[:content_type] || "text/plain" - }] + collect_responses_from_text(headers) else collect_responses_from_templates(headers) end end + def collect_responses_from_text(headers) + [{ + body: headers.delete(:body), + content_type: headers[:content_type] || self.class.default[:content_type] || "text/plain" + }] + end + def collect_responses_from_templates(headers) templates_path = headers[:template_path] || self.class.mailer_name templates_name = headers[:template_name] || action_name -- cgit v1.2.3 From 40b1f648b949f4ad944024619e546765e3729776 Mon Sep 17 00:00:00 2001 From: MQuy Date: Tue, 6 Dec 2016 10:13:54 +0800 Subject: Add document in mailer --- actionmailer/lib/action_mailer/base.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 2cb5c5514d..a7015b1e6d 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -208,6 +208,19 @@ module ActionMailer # end # end # + # You can also send attachments with html template, in this case you need to add body, attachments, + # and custom content type like this: + # + # class NotifierMailer < ApplicationMailer + # def welcome(recipient) + # attachments['free_book.pdf'] = File.read('path/to/file.pdf') + # mail(to: recipient, + # subject: "New account information", + # content_type: "text/html", + # body: "Hello there") + # end + # end + # # = Inline Attachments # # You can also specify that a file should be displayed inline with other HTML. This is useful -- cgit v1.2.3 From f091bd67b3ef5f4cd85dbd70cbd11e9ad2711562 Mon Sep 17 00:00:00 2001 From: MQuy Date: Fri, 6 Jan 2017 18:37:33 +0800 Subject: Remove unnecessary condition in content_type --- actionmailer/lib/action_mailer/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index a7015b1e6d..35c793351f 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -922,7 +922,7 @@ module ActionMailer def collect_responses_from_text(headers) [{ body: headers.delete(:body), - content_type: headers[:content_type] || self.class.default[:content_type] || "text/plain" + content_type: headers[:content_type] || "text/plain" }] end -- cgit v1.2.3