问题描述
我使用 Rails 6 和 ActionMailer 在用户加入时发送电子邮件。值得一提的是,我仅使用 API 应用程序并将其托管在 Heroku 上。
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8">
<Meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
<Meta http-equiv="X-UA-Compatible" content="ie=edge">
<Meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<div style="width: 100%;display: flex;flex-direction: column;align-items: center;padding: 15px;background-color: white;font-family: 'Helvetica';color: #2c3e50">
<h1>Welcome to company!</h1>
<div style="height: 1px;background-color: dimgrey;width: 50%;margin-top: 10px; margin-bottom: 20px;"></div>
<h4 style="margin:0">Want to learn more about our platform?</h4>
<p style="margin-bottom: 30px">Check out <a href="#">this</a> quick video guide.</p>
<h4 style="margin:0">Join our discord server</h4>
<h4 style="margin:0">Follow us on social media</h4>
<p style="margin-bottom: 30px">Some icons with social media</p>
<%= link_to "Create Password",@url,style: "color: white;padding:10px;border-radius:10px;margin-bottom:20px" %>
</div>
</body>
</html>
现在,预览中的这段代码将提供这种视图
这很好,这就是我想要的。
但是当用户在生产中收到它时,它看起来像这样
我是否使用了我不应该使用的东西?我如何使它看起来像预览中的样子。
这里还有一些您可能感兴趣的文件:
config.action_controller.asset_host = 'https://myapponheroku'
config.action_mailer.asset_host = config.action_controller.asset_host
config.action_mailer.perform_caching = false
config.action_mailer.delivery_method = :smtp
host = 'myapponheroki'
config.action_mailer.default_url_options = { host: host }
# smtp settings here
我的邮件位于 app/views/user_mailer
请询问您是否需要更多代码片段或信息。
解决方法
该屏幕截图使用了什么电子邮件客户端?可能只是电子邮件客户端问题和弹性。也许为了调试,您可以将视图更改为仅使用常规表,然后查看是否修复了格式。
此外,我过去曾成功地使用过这些。大多数主要电子邮件客户通常都能很好地处理它们。