class Easyemail
Constants
- VERSION
Attributes
to[RW]
Public Instance Methods
email(subject, content)
click to toggle source
# File lib/easyemail.rb, line 54 def email subject, content # content支持html if @config && @to if @to.respond_to? :each @to.each do | e | Mailer.send_email(@from, e, subject, content).deliver end else Mailer.send_email(@from, @to, subject, content).deliver end else raise "check smtp_settings and receiver!" end end
load_smtp_settings_from_yaml(path)
click to toggle source
# File lib/easyemail.rb, line 25 def load_smtp_settings_from_yaml path smtp = YAML.load_file(path) if smtp["provider"] # 如果指定了邮件服务商 就直接跳转到该服务商 # 待选列表 163, hhu, qq, gmail self.send("smtp_settings_for_#{smtp["provider"]}", smtp["user_name"], smtp["password"]) else self.smtp_settings smtp end end
smtp_settings(smtp)
click to toggle source
# File lib/easyemail.rb, line 36 def smtp_settings smtp # common settings for smtp, all provided by user. begin ActionMailer::Base.smtp_settings = { address: smtp['address'], port: smtp["port"], authentication: smtp["authentication"], user_name: smtp['user_name'], password: smtp['password'], enable_starttls_auto: smtp["enable_starttls_auto"] } @from = smtp["user_name"] @config = true rescue raise "wrong parameters for smtp settings." end end
support()
click to toggle source
# File lib/easyemail.rb, line 69 def support ret = [] @@config.each do | key, value | ret.push key end ret end