Class: CircularMail::Message
- Inherits:
-
Object
- Object
- CircularMail::Message
- Defined in:
- lib/circular-mail.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#body ⇒ Object
Returns the value of attribute body.
-
#character_set ⇒ Object
Returns the value of attribute character_set.
-
#format ⇒ Object
Returns the value of attribute format.
-
#header ⇒ Object
Returns the value of attribute header.
Instance Method Summary collapse
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
356 357 358 |
# File 'lib/circular-mail.rb', line 356 def @attachments end |
#body ⇒ Object
Returns the value of attribute body.
353 354 355 |
# File 'lib/circular-mail.rb', line 353 def body @body end |
#character_set ⇒ Object
Returns the value of attribute character_set.
355 356 357 |
# File 'lib/circular-mail.rb', line 355 def character_set @character_set end |
#format ⇒ Object
Returns the value of attribute format.
354 355 356 |
# File 'lib/circular-mail.rb', line 354 def format @format end |
#header ⇒ Object
Returns the value of attribute header.
352 353 354 |
# File 'lib/circular-mail.rb', line 352 def header @header end |
Instance Method Details
#get ⇒ Object
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/circular-mail.rb', line 398 def get() if @header.fields.length > 0 CircularMail::die("Date and From header fields must be present in the message as per RFC-2822!") if !@header.present?('Date') || !@header.present?('From') @header.add_field('Content-Transfer-Encoding', 'base64') unless header.present?('Content-Transfer-Encoding') = CircularMail::encode(@body, @header.get_field('Content-Transfer-Encoding')) if @format == 'text' content_type = 'text/plain' else content_type = 'text/html' end if @attachments.length == 0 @header.add_field('Content-Type', "#{content_type};charset=#{@character_set}") return "#{@header.get()}\r\n#{}" else @header.add_field('MIME-Version', '1.0') @header.add_field('Content-Type', "multipart/mixed; boundary=#{$message_id}") = "Content-Type:#{content_type}\r\nContent-Transfer-Encoding:base64\r\n\r\n#{}--#{$message_id}" return "#{@header.get()}\r\n--#{$message_id}\r\n#{}\r\n#{()}" end else CircularMail::die("Cannot generate message, because lack of header fields!") if CircularMail::config('strictness') return nil end end |