Module: Smail
- Defined in:
- lib/smail.rb,
lib/smail/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"
- @@options =
{}
- @@override_options =
{}
- @@subject_prefix =
false
- @@append_inputs =
false
Class Method Summary collapse
- .append_inputs ⇒ Object
-
.mail(options) ⇒ Object
Send an email Smail.mail(:to => ‘[email protected]’, :from => ‘[email protected]’, :subject => ‘hi’, :body => ‘Hello there.’) Smail.mail(:to => ‘[email protected]’, :html_body => ‘<h1>Hello there!</h1>’, :body => “In case you can’t read html, Hello there.”) Smail.mail(:to => ‘[email protected]’, :cc => ‘[email protected]’, :from => ‘[email protected]’, :subject => ‘hi’, :body => ‘Howsit!’).
- .options ⇒ Object
-
.options=(value) ⇒ Object
Default options can be set so that they don’t have to be repeated.
- .override_options ⇒ Object
- .override_options=(value) ⇒ Object
- .permissable_options ⇒ Object
- .subject_prefix(value) ⇒ Object
Class Method Details
.append_inputs ⇒ Object
43 44 45 |
# File 'lib/smail.rb', line 43 def self.append_inputs @@append_inputs = true end |
.mail(options) ⇒ Object
Send an email
Smail.mail(:to => '[email protected]', :from => '[email protected]', :subject => 'hi', :body => 'Hello there.')
Smail.mail(:to => '[email protected]', :html_body => '<h1>Hello there!</h1>', :body => "In case you can't read html, Hello there.")
Smail.mail(:to => '[email protected]', :cc => '[email protected]', :from => '[email protected]', :subject => 'hi', :body => 'Howsit!')
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/smail.rb', line 51 def self.mail() if @@append_inputs [:body] = "#{[:body]}/n #{.to_s}" end = @@options.merge = .merge @@override_options if @@subject_prefix [:subject] = "#{@@subject_prefix}#{[:subject]}" end fail ArgumentError, ':to is required' unless [:to] [:via] = default_delivery_method unless .key?(:via) if .key?(:via) && [:via] == :sendmail [:via_options] ||= {} [:via_options][:location] ||= sendmail_binary end deliver build_mail() end |
.options ⇒ Object
27 28 29 |
# File 'lib/smail.rb', line 27 def self.() @@options end |
.options=(value) ⇒ Object
Default options can be set so that they don’t have to be repeated.
Smail. = {
:from => '[email protected]',
:via => :smtp,
:via_options => {
:host => 'smtp.yourserver.com'
}
}
Smail.mail(:to => 'foo@bar') # Sends mail to foo@bar from [email protected] using smtp
Smail.mail(:from => '[email protected]', :to => 'foo@bar') # Sends mail to foo@bar from [email protected] using smtp
23 24 25 |
# File 'lib/smail.rb', line 23 def self.(value) @@options = value end |
.override_options ⇒ Object
35 36 37 |
# File 'lib/smail.rb', line 35 def self. @@override_options end |
.override_options=(value) ⇒ Object
31 32 33 |
# File 'lib/smail.rb', line 31 def self.(value) @@override_options = value end |
.permissable_options ⇒ Object
75 76 77 |
# File 'lib/smail.rb', line 75 def self. + end |
.subject_prefix(value) ⇒ Object
39 40 41 |
# File 'lib/smail.rb', line 39 def self.subject_prefix(value) @@subject_prefix = value end |