Class: TemplateMailer::MailMessage
- Inherits:
-
Object
- Object
- TemplateMailer::MailMessage
- Defined in:
- lib/template_mailer/mail_message.rb
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MailMessage
constructor
Hash…
-
#send(options = {}) ⇒ Object
(also: #dispatch)
This method attempts to send the contents of a mail message to a specified set of recipients.
Constructor Details
#initialize(options = {}) ⇒ MailMessage
Hash…
* :html - The HTML content for the email . Both this and
text can be specified but at least one of them should be.
* :text - The textual content for the email . Both this
and :html can be specified but at least one should be.
* :server - When SMTP is the preferred email mecahnism (see the
:via option) then this value should be a Hash of the parameters
that will be used to talk to the SMTP server.
* :via - The email mechanism to use to dispatch email .
are :sendmail (the default) or :smtp. If :smtp is
specified then the :server option should also be given a
value.
19 20 21 22 23 24 |
# File 'lib/template_mailer/mail_message.rb', line 19 def initialize(={}) @html = [:html] @text = .fetch(:text, [:txt]) @server = [:server] @via = .fetch(:via, :sendmail) end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
25 26 27 |
# File 'lib/template_mailer/mail_message.rb', line 25 def html @html end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
25 26 27 |
# File 'lib/template_mailer/mail_message.rb', line 25 def text @text end |
Instance Method Details
#send(options = {}) ⇒ Object Also known as: dispatch
This method attempts to send the contents of a mail message to a specified set of recipients.
Parameters
- options
-
A Hash of the options to be used when sending the email. Recognised keys in this Hash are :subject (a String containing the email title), :recipients (either a String or Array list of email addresses that the message should be sent to) and :from (the email address that will be set as the message source).
37 38 39 40 41 42 |
# File 'lib/template_mailer/mail_message.rb', line 37 def send(={}) if !.include?(:recipients) || [nil, "", []].include?([:recipients]) raise TemplateMailerError, "No recipients specified for email." end Pony.mail(send_settings()) end |