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 = {}) " From: \#{@username}\n To: \#{msg_data[:mailto]}\n Subject: \#{msg_data[:subject]}\n Date: \#{Time.now.rfc2822}\n Message-Id: \"\#{Digest::SHA2.hexdigest(Time.now.to_i.to_s)}@\#{@username.split('@').last}\"\n \n \#{msg_data[:body]}\n END_OF_MESSAGE\nend\n" |
#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 |