所以我正在为我的应用程序测试一个mailer gem(letter_opener)以在浏览器中查看电子邮件。
所以我有我的notifications_controller(由脚手架生成)。
然后发送我的邮件:
notification_mailer
class NotificationMailer < ApplicationMailer
default to: -> { "somelist@postbox.tu" },
from: -> { "info@postbox.tut" }
def notification_mailer(notification)
@notification = notification
@url = "http://postbox.tut/"
mail(:subject => "New Notification")
end
end
这是我的视图/ notification_mailer / notification_mailer视图
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></pre>
<h1>Notification email.</h1>
<h2><%= @notification.headline %></h2>
<pre>
<%= @notification.content %>
This email was sent out to you, because you are subscribed to the postbox-mailing-list.
If you want to unscribscribe, please use this url: <%= @url %>.
现在不能像昨天一样打开新标签(包含渲染的电子邮件)了。但是我的Rails控制台说:
Started POST "/notifications" for 127.0.0.1 at 2018-10-10 15:17:56 +0800
Processing by NotificationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"MgfddL8EHhDylDDVHqsvYLlQ2HO0fB1J9amMpty1HDqsjJGCJx0fpBfnlvRVeOUtxMc8Seq8L8lsxeZeGg3Aww==", "notification"=>{"headline"=>"Don", "content"=>"pogi pogi no mi\r\n"}, "commit"=>"Create Notification"}
Rendering notification_mailer/notification_mailer.html.erb within layouts/mailer
Rendered notification_mailer/notification_mailer.html.erb within layouts/mailer (0.7ms)
NotificationMailer#notification_mailer: processed outbound mail in 33.5ms
Sent mail to somelist@postbox.tu (23.4ms)
Date: Wed, 10 Oct 2018 15:17:56 +0800
From: info@postbox.tut
To: somelist@postbox.tu
Message-ID: <5bbda7a42ca92_5e7f2b0fe9be8a10789b3@don-300E4C-300E5C-300E7C.mail>
Subject: New Notification
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* Email styles need to be inline */
</style>
</head>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></pre>
<h1>Notification email.</h1>
<h2>Don</h2>
<pre>
pogi pogi no mi
This email was sent out to you, because you are subscribed to the postbox-mailing-list.
If you want to unscribscribe, please use this url: http://postbox.tut/.
</body>
</html>
检查我的tmp文件夹是否正在生成邮件。现在发生的事情是没有打开浏览器,而是在创建新帖子后始终打开空白的Visual Studio代码文件。
答案 0 :(得分:0)
我只是想出了这个。好像我不小心将默认的html查看器更改为文本编辑器一样。