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 CHANGED
@@ -31,7 +31,7 @@ ActionMailer::Base#deliverでを実際のメール送信ではなくジョブキ
31
31
 
32
32
  Gemfile
33
33
 
34
- gem 'queued_mail', git: 'git://github.com/uzuki05/queued_mail.git'
34
+ gem 'queued_mail', '= 0.1.1'
35
35
 
36
36
  bundle install
37
37
 
@@ -10,5 +10,6 @@ module QueuedMail
10
10
  config.mail_queue_service = :resque
11
11
  config.mail_queue_name = :mail_queue
12
12
  config.mail_queue_outbound_delivery_method = :sendmail
13
+ config.mail_queue_outbound_mailer = 'QueuedMail::Mailer'
13
14
  end
14
15
  end
@@ -6,10 +6,14 @@ module QueuedMail
6
6
  message = QueuedMail::Message.find(args["message_id"].to_i)
7
7
 
8
8
  message.lock!
9
- QueuedMail::Mailer.original_email(message).deliver
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
@@ -1,18 +1,5 @@
1
1
  module QueuedMail
2
2
  class Mailer < ActionMailer::Base
3
- self.delivery_method = Rails.application.config.mail_queue_outbound_delivery_method
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
@@ -1,3 +1,3 @@
1
1
  module QueuedMail
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/queued_mail.rb CHANGED
@@ -3,6 +3,7 @@ require "queued_mail/engine"
3
3
  module QueuedMail
4
4
  autoload :DeliveryMethod, 'queued_mail/delivery_method'
5
5
  autoload :Mailer, 'queued_mail/mailer'
6
+ autoload :OutboundMail, 'queued_mail/outbound_mail'
6
7
  autoload :Job, 'queued_mail/job'
7
8
 
8
9
  module Queue
@@ -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,5 @@
1
+ <p>こんにちは!
2
+ 日本語メールのテストです。
3
+ </p>
4
+ <p>Sending attachment in emails is easy.</p>
5
+
@@ -0,0 +1,4 @@
1
+ こんにちは!
2
+ 日本語メールのテストです。
3
+
4
+ Sending attachment in emails is easy.
@@ -0,0 +1,5 @@
1
+ <p>こんにちは!
2
+ 日本語メールのテストです。
3
+ </p>
4
+ <p>Sending attachment in emails is easy.</p>
5
+ <p>inline:<%= image_tag attachments['cat.jpg'].url %></p>
@@ -0,0 +1,5 @@
1
+ こんにちは!
2
+ 日本語メールのテストです。
3
+
4
+ Sending attachment in emails is easy.
5
+
@@ -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.
@@ -0,0 +1,6 @@
1
+ JpSampleMailer#simple_test
2
+
3
+ こんにちは!
4
+ 日本語メールのテストです。
5
+
6
+ <%= @greeting %>, find me in app/views/app/views/jp_sample_mailer/simple_test.text.erb
@@ -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 = :sendmail
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
@@ -0,0 +1,7 @@
1
+ development:
2
+ :address: smtp.gmail.com
3
+ :port: 587
4
+ :authentication: plain
5
+ :user_name: uzuki05@takeyu-web.com
6
+ :password: arowanadaisuki
7
+ :enable_starttls_auto: true
Binary file