· 9 years ago · Feb 16, 2017, 11:04 AM
1require '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
16options = { :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
24Mail.defaults do
25 delivery_method :smtp, options
26end
27
28def 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
37end
38
39
40sendMail("test", "Testing!!!!")