Module: OnlyofficeIredmailHelper::SendMessageMethods
- Included in:
- IredMailHelper
- Defined in:
- lib/onlyoffice_iredmail_helper/send_message_methods.rb
Overview
Methods to send message
Instance Method Summary collapse
-
#create_msg(msg_data = {}) ⇒ String
Form a email string.
-
#send_mail(options = {}) ⇒ nil
Send mail.
Instance Method Details
#create_msg(msg_data = {}) ⇒ String
Form a email string
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onlyoffice_iredmail_helper/send_message_methods.rb', line 9 def create_msg(msg_data = {}) <<~END_OF_MESSAGE From: #{@username} To: #{msg_data[:mailto]} Subject: #{msg_data[:subject]} Date: #{Time.now.rfc2822} Message-Id: "#{Digest::SHA2.hexdigest(Time.now.to_i.to_s)}@#{@username.split('@').last}" #{msg_data[:body]} END_OF_MESSAGE end |
#send_mail(options = {}) ⇒ nil
Send mail
24 25 26 27 28 29 30 31 |
# File 'lib/onlyoffice_iredmail_helper/send_message_methods.rb', line 24 def send_mail( = {}) [:subject] ||= @default_subject [:body] ||= @default_body [:mailto] ||= @default_user smtp = Net::SMTP.start(@domainname, 25, @username, @username, @password, :login) smtp. create_msg(), @username, [:mailto] smtp.finish end |