I need help with e-mail templates. I have an html template with three embedded images in it. I am using the restful authentication plugin and have tried to customize the default mailer. The template works great as a standalone webpage but for some reason is not rendering properly with the images. I can either get the images to attach but not render inline, or the don't attach at all.
Anyway the mailer is as follows:
class UserMailer < ActionMailer::Base
def signup_notification(user)
setup_email(user)
@subject << 'Please activate your thredUP account'
@body[:url] = "#{APP_CONFIG[:site_url]}/activate/#{user.activation_code}"
end
def activation(user)
setup_email(user)
@subject << 'Your account has been activated - Welcome to thredUP!'
@url = APP_CONFIG[:site_url]
@user = user
content_type "text/html"
attachment :content_type => "image/gif", :body => File.read("#{Rails.root}/public/images/email/bottom-border.gif")
attachment :content_type => "image/gif", :body => File.read("#{Rails.root}/public/images/email/top-border.gif")
attachment :content_type => "image/png", :body => File.read("#{Rails.root}/public/images/email/footer.png")
attachment :content_type => "image/png", :body => File.read("#{Rails.root}/public/images/email/logo-lid.png")
render :layout => 'standard'
end
protected
def setup_email(user)
@recipients = "#{user.email}"
@from = APP_CONFIG[:admin_email]
@subject = "[#{APP_CONFIG[:site_name]}] "
@sent_on = Time.now
@body[:user] = user
end
end
I have also built the template as follows:
<html>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" bgcolor='#EFEFEF' >
<table width="100%" cellpadding="10" cellspacing="40" border="0" class="backgroundTable" bgcolor='#EFEFEF' >
<tr>
<td valign="top" align="center">
<table width="600" cellpadding="0" cellspacing="0">
<tr>
<td style="padding-bottom:15px;"><img src="cid:logo-lid.png"> </td>
</tr>
</table>
<table width="600" cellpadding="0" cellspacing="0">
<tr>
<td><img src="cid:top-border.gif"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td style="padding:20px;">
<%= yield %>
</td>
</tr>
<tr>
<td><img src="cid:bottom-border.gif"></td>
</tr>
<tr>
<td style="text-align:center; padding-top:15px;">
<img src="cid:footer.png">
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>