Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.19 KB | None | 0 0
  1. require 'mail'
  2.  
  3. @sendAddress = "smtp.gmail.com"
  4. @sendPort = 587
  5. @sendDomain = "gmail.com"
  6. ## CHANGE THIS TO YOUR USER NAME
  7. @sendUserName = "gemstoneruby.smtp" # this is your username excluding @gmail.com
  8. @sendPassword = "xxxxx" # CHANGE
  9. @fromEmail = "gemstoneruby.smtp@gmail.com" # ex, gemstoneruby@gmail.com
  10.  
  11. ## TO EMAILS - Max of 2 emails currently
  12. @email1 = "4158889990@msg.fi.google.com"  # example of email to text for ATT
  13. @email2 = "brycole@gmail.com" # Email notification is sent here.
  14.  
  15.  
  16. options = { :address              => @sendAddress,
  17.             :port                 => @sendPort,
  18.             :domain               => @sendDomain,
  19.             :user_name            => @sendUserName,
  20.             :password             => @sendPassword,
  21.             :authentication       => 'plain', # this might need to change if you don't use gmail.
  22.             :enable_starttls_auto => true  }
  23.  
  24. Mail.defaults do
  25.   delivery_method :smtp, options
  26. end
  27.  
  28. def sendMail(message, type)
  29.   for toEmail in [@email1, @email2]
  30.     Mail.new(
  31.       to:       toEmail,
  32.       from:     @fromEmail,
  33.       subject:  type,
  34.       body:     message
  35.     ).deliver!
  36.   end
  37. end
  38.  
  39.  
  40. sendMail("test", "Testing!!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement