class FeedTorrents::Mail
Constants
- PREFIX
Public Instance Methods
send_email(subject, body)
click to toggle source
# File lib/feed_torrents/mail.rb, line 11 def send_email(subject, body) return unless FeedTorrents.configuration.email[:enabled] mail(subject: "#{PREFIX}#{subject}", body: body) end
send_test_email()
click to toggle source
# File lib/feed_torrents/mail.rb, line 7 def send_test_email mail(subject: "#{PREFIX}Test email", body: 'test email') end
Private Instance Methods
delivery_arguments()
click to toggle source
# File lib/feed_torrents/mail.rb, line 49 def delivery_arguments args = FeedTorrents.configuration.email[:delivery_method].dup args.delete(delivery_method) args end
delivery_method()
click to toggle source
# File lib/feed_torrents/mail.rb, line 41 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
mail(args)
click to toggle source
# File lib/feed_torrents/mail.rb, line 23 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.charset = 'UTF-8' obj.deliver end
to()
click to toggle source
# File lib/feed_torrents/mail.rb, line 19 def to FeedTorrents.configuration.email[:to] end