首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在rails的注册邮件中设置网站徽标图像?

如何在rails的注册邮件中设置网站徽标图像?
EN

Stack Overflow用户
提问于 2017-03-09 13:18:55
回答 2查看 249关注 0票数 0

我正在使用rails 5当用户在我的网站注册时,我正在为他发送一封电子邮件以获得帐户批准。我想用电子邮件设置网站徽标。我们如何在rails邮件视图文件中实现这一点

邮件模板的Html

代码语言:javascript
复制
<!DOCTYPE HTML>
<html>
<title>nytApp Email</title>
    <head>
    </head>
    <body style="font-family: 'arial', sans-serif !important;   font-size: 14px;   line-height: 20px;  color:#3e3e3e; background-color: #f5f5f5; font-weight: 300;">
        <!-- Container Table -->
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" width="640" style="margin:0 auto; background:#fff;">
                        <tr>
                            <td style="border: 1px solid #f5cd8f;">
                                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                    <tr>
                                        <td style="padding: 25px 15px 20px; border-bottom: 1px solid #f5cd8f;">
                                            <table  align="center" cellpadding="0" cellspacing="0" border="0" width="100%">
                                                <tr>
                                                    <td><%= image_path('logo.png')%></td>
                                                    <td>
                                                        <table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-weight: bold; font-size: 16px;">
                                                            <tr>
                                                                <td style="color: #ff5e00; font-weight: 300; font-size: 20px;">Welcome to Nytapp</td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="padding: 0 15px 20px;">
                                            <table  align="center" cellpadding="0" cellspacing="0" border="0" width="100%">
                                                <tr><td height="10"></td></tr>
                                                <tr>
                                                    <td>Thank you for signing up as Events Promoter!</td>
                                                </tr>
                                                <tr><td height="25"></td></tr>
                                                <tr>
                                                    <td>You are ready to start posting your parties for free. Login to the portal by clicking on the link below:</td>
                                                </tr>
                                                <tr><td height="10"></td></tr>
                                                <tr>
                                                    <td><a href="https://night-app.herokuapp.com/admin" style="color: #00a8ff;">https://nytapp.com</a></td>
                                                </tr>
                                                <tr><td height="10"></td></tr>
                                                <tr>
                                                    <td>If the above URL does not work try copying and pasting it into your browser.</td>
                                                </tr>
                                                <tr><td height="8"></td></tr>
                                                <tr>
                                                    <td>If you encounter any problem, please contact us at <a href="mailto:admin@nytapp.com" style="color: #333; font-weight: bold; text-decoration: none;">admin@nytapp.com</a></td>
                                                </tr>
                                                <tr><td height="25"></td></tr>
                                                <tr>
                                                    <td>Thank you,</td>
                                                </tr>
                                                <tr>
                                                    <td>The Nytapp team</td>
                                                </tr>
                                                <tr><td height="30"></td></tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border-top: 1px solid #f5cd8f; vertical-align: middle;  padding: 10px 15px;">
                                            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                                <tr>
                                                    <td>
                                                        <%= image_path('logo.png') %>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>
EN

回答 2

Stack Overflow用户

发布于 2017-03-09 13:26:49

在邮件中,你不能给出相对路径。因此,尝试将您的徽标上传到云中的某个位置,如s3,并在图像标签源中给出完整的徽标url。

您也可以使用asset_url来计算完整url。

代码语言:javascript
复制
<%= image_tag asset_url('logo.png') %>
票数 1
EN

Stack Overflow用户

发布于 2017-03-09 17:01:36

在本应作为邮件发送的html.erb文件中,您需要编写类似下面这样的内容。

代码语言:javascript
复制
<img src=" <%= Rails.application.secrets.host + "" +  asset_path("sd_logo.png") %>"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42687324

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档