Hello everyone, I’m using a gem called aws-ses and I’m trying to
sophisticate the email I am sending, here is the code currently:
ses = AWS::SES::Base.new(:access_key_id => ‘foo’, :secret_access_key =>
‘bar’)
email ={
:to => “#{subscriber.email}”,
:source => “’#{ag.name}’ <no-reply@#{ag.domain}>’”,
:subject => ‘Hello’,
:html_body => “
#{subscriber.name}
”
}
ses.send_email email
However, instead of passing a hard coded string to the :html_body key, I
want to pass a template in app/views/layouts/mail.html.erb
Is there any method/Rails helper that lets me convert an entire template
to string and pass to the html_body key?
P.S: If you have already used this gem and know a/another way to help me
please do it 
Thanks in advance, everyone!
On Thu, Aug 18, 2011 at 11:09 PM, Rodrigo Alves V.
[email protected]wrote:
:subject => ‘Hello’,
P.S: If you have already used this gem and know a/another way to help me
please do it 
Sorry, I haven’t used the gem yet but if you want to evaluate an erb
file,
you might want to check out the ERB class.
http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
–
Rodrigo Alves V. wrote in post #1017309:
Hello everyone, I’m using a gem called aws-ses and I’m trying to
sophisticate the email I am sending, here is the code currently:
ses = AWS::SES::Base.new(:access_key_id => ‘foo’, :secret_access_key =>
‘bar’)
email ={
:to => “#{subscriber.email}”,
:source => “’#{ag.name}’ <no-reply@#{ag.domain}>’”,
:subject => ‘Hello’,
:html_body => “
#{subscriber.name}
”
}
ses.send_email email
However, instead of passing a hard coded string to the :html_body key, I
want to pass a template in app/views/layouts/mail.html.erb
Is there any method/Rails helper that lets me convert an entire template
to string and pass to the html_body key?
An erb template is a string. File I/O is one of the most basic concepts
in ruby:
str = “”
File.open(‘path/to/file.txt’, ‘r’) do |f|
str << f.read
end