Sha256: 20cd79c91b889920fb47e94a591efa8e00f897f5669803c87d828430f8e073ef
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 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) return unless FeedTorrents.configuration.email[:enabled] mail(subject: "#{PREFIX}#{subject}", body: 'See subject! :-)') 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.0 | lib/feed_torrents/mail.rb |