Sha256: 532e7c4fce7a7a115e52dc5266482e6a465db871d32fdaa819fe892e1812ce4e
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
def require_local(file) require File.join(File.dirname(__FILE__), 'chimpster', file) end require_local 'message_extensions/shared' require_local 'message_extensions/mail' require_local 'handlers/mail' require 'logging' module Chimpster MAX_RETRIES = 2 class << self attr_accessor :api_key, :to, :from, :max_retries, :sleep_between_retries , :uakari, :logger def logger Logging.logger(STDOUT) end def max_retries @max_retries ||= 3 end def sleep_between_retries @sleep_between_retries ||= 10 end def configure yield self end def send (message) response = @uakari.send_email(message) response end def send_through_chimpster(message) #:nodoc: puts 'sending email' @retries = 0 _from = message['from'].to_s _from = @from unless @from == nil _to =message['to'].to_s _to = @to unless @to == nil _html = message.body_html _text = message.body_text options= { :text => _text, :html => _html, :subject => message.subject, :from_email => _from, :to_email => _to.split(','), :reply_to => _from.split(',') } response = self.send({ :track_opens => true, :track_clicks => true, :message => options, :tags => (message.tag.to_s if message.tag) }) c=response['status'] v= ['queued','sent'].include?(c) if v == false logger.info "ERROR Sending Email via Chimpster #{response.to_s}" else logger.info "Email Sent via Chimpster #{response.to_s}" end v end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chimpster-0.1.21 | lib/chimpster.rb |
chimpster-0.1.20 | lib/chimpster.rb |