queued_mail 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/queued_mail/engine.rb +1 -0
- data/lib/queued_mail/job.rb +5 -1
- data/lib/queued_mail/mailer.rb +1 -14
- data/lib/queued_mail/outbound_mail.rb +24 -0
- data/lib/queued_mail/version.rb +1 -1
- data/lib/queued_mail.rb +1 -0
- data/test/dummy/app/mailers/jp_sample_mailer.rb +30 -0
- data/test/dummy/app/views/jp_sample_mailer/attachment_test.html.erb +5 -0
- data/test/dummy/app/views/jp_sample_mailer/attachment_test.text.erb +4 -0
- data/test/dummy/app/views/jp_sample_mailer/inline_attachment_test.html.erb +5 -0
- data/test/dummy/app/views/jp_sample_mailer/inline_attachment_test.text.erb +5 -0
- data/test/dummy/app/views/jp_sample_mailer/multipart_test.html.erb +4 -0
- data/test/dummy/app/views/jp_sample_mailer/multipart_test.text.erb +4 -0
- data/test/dummy/app/views/jp_sample_mailer/simple_test.text.erb +6 -0
- data/test/dummy/config/environments/development.rb +5 -1
- data/test/dummy/config/smtp_settings.yml +7 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +27879 -0
- data/test/dummy/test/functional/jp_sample_mailer_test.rb +36 -0
- metadata +38 -7
data/README.rdoc
CHANGED
data/lib/queued_mail/engine.rb
CHANGED
data/lib/queued_mail/job.rb
CHANGED
@@ -6,10 +6,14 @@ module QueuedMail
|
|
6
6
|
message = QueuedMail::Message.find(args["message_id"].to_i)
|
7
7
|
|
8
8
|
message.lock!
|
9
|
-
|
9
|
+
mailer.original_email(message).deliver
|
10
10
|
message.destroy
|
11
11
|
rescue ActiveRecord::RecordNotFound => e
|
12
12
|
# nothing raises
|
13
13
|
end
|
14
|
+
|
15
|
+
def self.mailer
|
16
|
+
@mailer ||= instance_eval(Rails.application.config.mail_queue_outbound_mailer)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
data/lib/queued_mail/mailer.rb
CHANGED
@@ -1,18 +1,5 @@
|
|
1
1
|
module QueuedMail
|
2
2
|
class Mailer < ActionMailer::Base
|
3
|
-
|
4
|
-
layout nil
|
5
|
-
|
6
|
-
def original_email(message)
|
7
|
-
mail = mail(:from => message.formatted_sender,
|
8
|
-
:to => message.formatted_recipient,
|
9
|
-
:reply_to => message.formatted_reply_to,
|
10
|
-
:subject => message.subject,
|
11
|
-
:content_type => message.content_type,
|
12
|
-
:mime_version => message.mime_version,
|
13
|
-
:content_transfer_encoding => message.content_transfer_encoding)
|
14
|
-
|
15
|
-
mail.body = message.body
|
16
|
-
end
|
3
|
+
include QueuedMail::OutboundMail
|
17
4
|
end
|
18
5
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module QueuedMail
|
2
|
+
module OutboundMail
|
3
|
+
def self.included(klass)
|
4
|
+
klass.class_eval do
|
5
|
+
self.delivery_method = Rails.application.config.mail_queue_outbound_delivery_method
|
6
|
+
layout nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def original_email(message)
|
11
|
+
mail = mail(:from => message.formatted_sender,
|
12
|
+
:to => message.formatted_recipient,
|
13
|
+
:reply_to => message.formatted_reply_to,
|
14
|
+
:subject => message.subject,
|
15
|
+
:mime_version => message.mime_version,
|
16
|
+
:content_transfer_encoding => message.content_transfer_encoding)
|
17
|
+
unless message.content_type.blank?
|
18
|
+
mail.header[:content_type].value = Mail::ContentTypeField.new(message.content_type).value
|
19
|
+
end
|
20
|
+
mail.body = message.body
|
21
|
+
mail
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/queued_mail/version.rb
CHANGED
data/lib/queued_mail.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'jpmobile'
|
2
|
+
class JpSampleMailer < Jpmobile::Mailer::Base
|
3
|
+
default from: "from@takeyu-web.com"
|
4
|
+
|
5
|
+
# Subject can be set in your I18n file at config/locales/en.yml
|
6
|
+
# with the following lookup:
|
7
|
+
#
|
8
|
+
# en.sample_mailer.simple.subject
|
9
|
+
#
|
10
|
+
def simple_test
|
11
|
+
@greeting = "Hi"
|
12
|
+
|
13
|
+
mail to: '"Yuichi Takeuchi" <uzuki05@takeyu-web.com>'
|
14
|
+
end
|
15
|
+
|
16
|
+
def multipart_test
|
17
|
+
mail to: '"Yuichi Takeuchi" <uzuki05@takeyu-web.com>'
|
18
|
+
end
|
19
|
+
|
20
|
+
def attachment_test
|
21
|
+
attachments['cat.jpg'] = File.read(File.join(Rails.root, 'file/cat.jpg'))
|
22
|
+
mail to: '"Yuichi Takeuchi" <uzuki05@takeyu-web.com>'
|
23
|
+
end
|
24
|
+
|
25
|
+
def inline_attachment_test
|
26
|
+
attachments.inline['cat.jpg'] = File.read(File.join(Rails.root, 'file/cat.jpg'))
|
27
|
+
mail to: '"Yuichi Takeuchi" <uzuki05@takeyu-web.com>'
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<p>こんにちは!<br />
|
2
|
+
日本語メールのテストです。
|
3
|
+
</p>
|
4
|
+
<p>Multipart messages can also be used implicitly because Action Mailer will automatically detect and use multipart templates, where each template is named after the name of the action, followed by the content type. Each such detected template will be added as a separate part to the message.</p>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
こんにちは!
|
2
|
+
日本語メールのテストです。
|
3
|
+
|
4
|
+
Multipart messages can also be used implicitly because Action Mailer will automatically detect and use multipart templates, where each template is named after the name of the action, followed by the content type. Each such detected template will be added as a separate part to the message.
|
@@ -36,5 +36,9 @@ Dummy::Application.configure do
|
|
36
36
|
config.assets.debug = true
|
37
37
|
|
38
38
|
#config.action_mailer.delivery_method = :sendmail
|
39
|
-
config.mail_queue_outbound_delivery_method = :
|
39
|
+
config.mail_queue_outbound_delivery_method = :smtp
|
40
|
+
if FileTest.file?("#{Rails.root.to_s}/config/smtp_settings.yml")
|
41
|
+
smtp_settings = YAML::load(File.open("#{Rails.root.to_s}/config/smtp_settings.yml"))
|
42
|
+
ActionMailer::Base.smtp_settings = smtp_settings[Rails.env] unless smtp_settings[Rails.env].nil?
|
43
|
+
end
|
40
44
|
end
|
Binary file
|