Class: Hanami::Mailer::Message Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/mailer/message.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents an email message

Since:

  • 3.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, subject:, to: nil, cc: nil, bcc: nil, reply_to: nil, return_path: nil, html_body: nil, text_body: nil, attachments: [], headers: {}, charset: "UTF-8", delivery_options: {}) ⇒ Message

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new message

Parameters:

  • from (String, Array<String>)

    sender address(es)

  • to (String, Array<String>, nil) (defaults to: nil)

    recipient address(es)

  • cc (String, Array<String>, nil) (defaults to: nil)

    carbon copy address(es)

  • bcc (String, Array<String>, nil) (defaults to: nil)

    blind carbon copy address(es)

  • reply_to (String, Array<String>, nil) (defaults to: nil)

    reply-to address(es)

  • return_path (String, Array<String>, nil) (defaults to: nil)

    return path address(es) for bounces

  • subject (String)

    email subject

  • html_body (String, nil) (defaults to: nil)

    HTML body content

  • text_body (String, nil) (defaults to: nil)

    plain text body content

  • attachments (Array<Attachment>) (defaults to: [])

    array of attachments

  • headers (Hash) (defaults to: {})

    additional email headers

  • charset (String) (defaults to: "UTF-8")

    character encoding (default: "UTF-8")

  • delivery_options (Hash) (defaults to: {})

    delivery-method-specific options

Since:

  • 3.0.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hanami/mailer/message.rb', line 32

def initialize(from:, subject:, to: nil, cc: nil, bcc: nil, reply_to: nil, return_path: nil,
               html_body: nil, text_body: nil, attachments: [], headers: {}, charset: "UTF-8",
               delivery_options: {})
  @from = normalize_addresses(from)
  @to = normalize_addresses(to)
  @cc = normalize_addresses(cc)
  @bcc = normalize_addresses(bcc)
  @reply_to = normalize_addresses(reply_to)
  @return_path = normalize_addresses(return_path)
  @subject = subject
  @html_body = html_body
  @text_body = text_body
  @attachments = attachments
  @headers = headers
  @charset = charset
  @delivery_options = delivery_options

  validate_sender!
  validate_recipients!
end

Instance Attribute Details

#attachmentsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



13
14
15
# File 'lib/hanami/mailer/message.rb', line 13

def attachments
  @attachments
end

#bccObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def bcc
  @bcc
end

#ccObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def cc
  @cc
end

#charsetObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



13
14
15
# File 'lib/hanami/mailer/message.rb', line 13

def charset
  @charset
end

#delivery_optionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



13
14
15
# File 'lib/hanami/mailer/message.rb', line 13

def delivery_options
  @delivery_options
end

#fromObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def from
  @from
end

#headersObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



13
14
15
# File 'lib/hanami/mailer/message.rb', line 13

def headers
  @headers
end

#html_bodyObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



13
14
15
# File 'lib/hanami/mailer/message.rb', line 13

def html_body
  @html_body
end

#reply_toObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def reply_to
  @reply_to
end

#return_pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def return_path
  @return_path
end

#subjectObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def subject
  @subject
end

#text_bodyObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



13
14
15
# File 'lib/hanami/mailer/message.rb', line 13

def text_body
  @text_body
end

#toObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



10
11
12
# File 'lib/hanami/mailer/message.rb', line 10

def to
  @to
end

Instance Method Details

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert message to hash representation

Returns:

  • (Hash)

Since:

  • 3.0.0



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/hanami/mailer/message.rb', line 58

def to_h
  {
    from: from,
    to: to,
    cc: cc,
    bcc: bcc,
    reply_to: reply_to,
    return_path: return_path,
    subject: subject,
    html_body: html_body,
    text_body: text_body,
    attachments: attachments,
    headers: headers,
    charset: charset,
    delivery_options: delivery_options
  }
end