我再次提出几乎相同的问题,但我仍然没有找到解决问题的方法。我想在发布文章时向我的所有用户发送邮件。我想我已经成功设置了ActionMailer,因为我使用MailCatcher来查看邮件是否正常,我是否正确捕获邮件,但邮件没有到达收件箱。
Development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
user_name: 'mailaxessrails@gmail.com',
password: '********',
authentication: 'plain',
enable_starttls_auto: true }
来自MailCatcher的来源
Date: Mon, 08 Jun 2015 07:39:44 -0700
From: mailaxessrails@gmail.com
To: contact@******.com
Message-ID: <5575a930a739c_f723f9271aa20c432045@localhost.localdomain.mail>
Subject: **TEST**
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5575a930a3eb8_f723f9271aa20c4319c";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_5575a930a3eb8_f723f9271aa20c4319c
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
*******************************
===============================================
----==_mimepart_5575a930a3eb8_f723f9271aa20c4319c
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<body>
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>oooooooooooooooooooooo</h1>
</body>
</html>
</body>
</html>
----==_mimepart_5575a930a3eb8_f723f9271aa20c4319c--
我真的不知道如何解决这个问题,我没有错误,但它没有工作。我该怎么做才能让它发挥作用?
答案 0 :(得分:1)
您错过了default_url_options
,Reference
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
user_name: 'mailaxessrails@gmail.com',
password: '********',
authentication: 'plain',
enable_starttls_auto: true
}