【发布时间】:2021-01-04 00:13:25
【问题描述】:
当用户加入时,我正在使用 Rails 6 和 ActionMailer 发送电子邮件。提到我只使用 API 应用程序并将其托管在 Heroku 上可能也很重要。
我有一个.html.erb 视图设置,它看起来像这样:
<!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>
这很好,这就是我想要的。
我是否使用了我不应该使用的东西?如何让它看起来像预览中的样子。
这里还有一些您可能感兴趣的文件:
我添加到 production.rb 的有关邮件的内容:
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
如果您需要更多代码 sn-ps 或信息,请询问。
【问题讨论】:
标签: ruby-on-rails email actionmailer rails-api