Module: Mail::TmailTools
- Included in:
- EmailToSms
- Defined in:
- lib/mail/tmail_tools.rb
Instance Method Summary collapse
-
#get_receiver_from_subject(tmail) ⇒ Object
Extracts the receiver’s number from the email subject.
-
#plain_text_body_from_multipart(tmail) ⇒ Object
Extraxt the plain text body from a multipart email.
-
#puts_tmail(tmail) ⇒ Object
Prints the given tmail object to stdout.
-
#tmail_to_plaintext(tmail) ⇒ Object
If it is a multipart email with a plain text part it searches for the text/plain part of the mail and returns it.
Instance Method Details
#get_receiver_from_subject(tmail) ⇒ Object
Extracts the receiver’s number from the email subject
14 15 16 |
# File 'lib/mail/tmail_tools.rb', line 14 def get_receiver_from_subject(tmail) return tmail.subject(@charset).strip end |
#plain_text_body_from_multipart(tmail) ⇒ Object
Extraxt the plain text body from a multipart email
31 32 33 34 35 36 37 38 |
# File 'lib/mail/tmail_tools.rb', line 31 def plain_text_body_from_multipart(tmail) ret = nil tmail.parts.each do |part| ret = part.body(@charset) if part.content_type == 'text/plain' break end ret end |
#puts_tmail(tmail) ⇒ Object
Prints the given tmail object to stdout
5 6 7 8 9 10 11 |
# File 'lib/mail/tmail_tools.rb', line 5 def puts_tmail(tmail) puts "\n\n-----------------------" puts "E-Mail message:" puts tmail.subject puts tmail_to_plaintext(tmail) puts "-----------------------\n\n" end |
#tmail_to_plaintext(tmail) ⇒ Object
If it is a multipart email with a plain text part it searches for the text/plain part of the mail and returns it.
20 21 22 23 24 25 26 27 28 |
# File 'lib/mail/tmail_tools.rb', line 20 def tmail_to_plaintext(tmail) ret = nil if tmail.multipart? then plain_text_body_from_multipart(tmail) else ret = tmail.body(@charset) end ret end |