2

電子メールテンプレートについてサポートが必要です。3つの画像が埋め込まれたhtmlテンプレートがあります。私はRESTful認証プラグインを使用しており、デフォルトのメーラーをカスタマイズしようとしました。テンプレートはスタンドアロンのWebページとしてはうまく機能しますが、何らかの理由で画像で適切にレンダリングされません。画像を添付してもインラインでレンダリングできないか、まったく添付しないかのどちらかです。

とにかくメーラーは次のとおりです。

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>                     
4

2 に答える 2

3

サーバーでホストしてから電子メールで参照するのではなく、添付する必要がある特別な理由はあります<img src="http://your.server/image.png" />か(例)。

私はそれがそれを単純化するだろうと想像します。

于 2009-08-16T15:50:54.910 に答える
0

それらをアタッチすることを主張する場合は、JasonKingのinline_attachmentgemを使用してみてください。静止画像に最適です。

リンク: http: //github.com/JasonKing/inline_attachment/tree/master

于 2009-08-17T06:47:32.420 に答える