Module: EmailHelper
- Included in:
- TmcHelpers
- Defined in:
- lib/helpers/tmc_helpers/email_helper/email_helper.rb
Instance Method Summary collapse
-
#send_email(subject, body, to, endpoint: nil, username: nil, password: nil) ⇒ Object
Public: Sends an email.
-
#send_email_setup(endpoint, username, password) ⇒ Object
Public: Configures email.
Instance Method Details
#send_email(subject, body, to, endpoint: nil, username: nil, password: nil) ⇒ Object
Public: Sends an email.
subject - String email subject. body - String email message body. to - String or Array of String recipient email addresses. endpoint - String EWS endpoint URL (default: nil). username - String EWS account username (default: nil). password - String EWS account password (default: nil).
Returns nothing.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/helpers/tmc_helpers/email_helper/email_helper.rb', line 19 def send_email(subject, body, to, endpoint: nil, username: nil, password: nil) logger.debug(%Q(Sending email to #{to} with subject "#{subject}" [#{body.length} chars])) @spam_sleep = @last_email_time.nil? ? 0 : 60 - (Time.now - @last_email_time) if @spam_sleep > 0 sleep(@spam_sleep.to_i.sec) end with_ews_client(endpoint, username, password) do |cli| cli. do |m| m.subject = subject m.body = body if to.is_a?(Array) to.each {|r| m.to_recipients << r} else m.to_recipients << to end end @last_email_time = Time.now end end |
#send_email_setup(endpoint, username, password) ⇒ Object
Public: Configures email.
endpoint - String EWS endpoint URL. username - String EWS account username. password - String EWS account password.
Returns nothing.
46 47 48 |
# File 'lib/helpers/tmc_helpers/email_helper/email_helper.rb', line 46 def send_email_setup(endpoint, username, password) with_ews_client(endpoint, username, password) { } end |