Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rake task to send emails for testing purpose #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@ end

multitask "build" => ["build:sass", "build:coffee"]

desc "Send mails for testing"
task "test:send", :number do |t, args|
require 'mail'
require 'pathname'
require 'active_support/core_ext/array/random_access'
require 'active_support/core_ext/object/blank'

number = (args[:number] || 10).to_i
ip, port = '127.0.0.1', 1025
ip = ENV['SMTP_IP'] if ENV['SMTP_IP'].present?
port = ENV['SMTP_PORT'].to_i if ENV['SMTP_PORT'].present?
mails = Pathname.glob('examples/*')

Mail.defaults do
delivery_method :smtp,
:address => ip,
:port => port
end

$stderr.puts "Sending #{number} mails to #{ip}:#{port}"
number.times do |n|
message = Mail.new mails.sample.read
message.subject += " (#{n + 1})"
message.deliver
end
end

desc "Package as Gem"
task "package:gem" do
Gem::Package.build spec
Expand Down