gpt4 book ai didi

ruby-on-rails - Ruby on Rails 中的电子邮件模板

转载 作者:行者123 更新时间:2023-12-04 07:04:46 25 4
gpt4 key购买 nike

我需要有关电子邮件模板的帮助。我有一个包含三个嵌入图像的 html 模板。我正在使用 restful 身份验证插件并尝试自定义默认邮件程序。该模板作为一个独立的网页效果很好,但由于某种原因无法正确渲染图像。我可以让图像附加但不内联渲染,或者根本不附加。

无论如何,邮件如下:

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

我还构建了如下模板:
<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>

最佳答案

是否有任何特殊原因需要将它们附加而不是托管在您的服务器上,然后在电子邮件中引用(例如 <img src="http://your.server/image.png" /> )?

我想这会简化它。

关于ruby-on-rails - Ruby on Rails 中的电子邮件模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1284469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com