Sha256: d85d6afe9e1e1fefa1c3b7d62d8c1dad8eb8b70aa8ac123e059530900923b532
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module FeedTorrents class Mail include LogFunctions PREFIX = "[FeedTorrents] " def send_test_email mail(subject: "#{PREFIX}Test email", body: 'test email') end def send_email(subject, body) return unless FeedTorrents.configuration.email[:enabled] mail(subject: "#{PREFIX}#{subject}", body: body) end private def to FeedTorrents.configuration.email[:to] end def mail(args) obj = ::Mail.new options = { to: FeedTorrents.configuration.email[:to], from: FeedTorrents.configuration.email[:from] }.merge(args) options.each { |k,v| obj[k] = v} obj.delivery_method delivery_method, delivery_arguments info "Sending an email to #{options[:to].inspect} with subject: #{options[:subject].inspect}" obj.deliver end def delivery_method [:smtp, :sendmail, :exim].each do |sym| return sym if FeedTorrents.configuration.email[:delivery_method][sym] end raise ArgumentError, 'Unknown delivery method' end def delivery_arguments args = FeedTorrents.configuration.email[:delivery_method].dup args.delete(delivery_method) args end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
feed_torrents-0.2.1 | lib/feed_torrents/mail.rb |