I have a ruby file which I use to send email. I am using the code from a tutorial as follows:
require 'net/smtp'
test_arr = ["test", "test1"]
message = <<MESSAGE_END
From: Private Person <[email protected]>
To: A Test User <[email protected]>
MIME-Version: 1.0
Content-type: text/html
Subject: SMTP e-mail test
This is an e-mail message to be sent in HTML format
<b>This is HTML message.</b>
<h1>This is headline.</h1>
//Here I want to iterate through the Array test_arr and create a h1 element for each element in array
<h1> test </h1>
<h1> test1 </h1>
MESSAGE_END
Net::SMTP.start('localhost') do |smtp|
smtp.send_message message, '[email protected]',
'[email protected]'
end
I have tried <% to inject ruby code to iterate the array but does not seem to work. How could I iterate through the test_arr Array inside that HTML message?