gpt4 book ai didi

ruby-on-rails - Rails 应用程序可以从本地主机发送电子邮件吗?

转载 作者:行者123 更新时间:2023-12-02 21:51:33 24 4
gpt4 key购买 nike

我认为我已成功设置 ActionMailer,但是电子邮件并未到达收件箱,尽管服务器的说明有所不同:

Sent mail to <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbd1ced7d2dad5fbdfdec8d2dcd5d2d6cbdec9d2dad795d8d4d6" rel="noreferrer noopener nofollow">[email protected]</a> (2003ms)
Date: Fri, 30 Aug 2013 22:26:41 +0100
From: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d5b4f52507d58455c504d5158135e5250" rel="noreferrer noopener nofollow">[email protected]</a>
To: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="600a150c09010e20070d01090c4e030f0d" rel="noreferrer noopener nofollow">[email protected]</a>
Message-ID: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8bbeb9b9babbeebabae9eeefe8b2d4babdbebbbaefb3bfedbdbfb9bebceacbc1fee7e2eae5a6dbc8a5e6eae2e7" rel="noreferrer noopener nofollow">[email protected]</a>>
Subject: Welcome to my awesome site!
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Welcome to example.com, Julian</h1>
<p>
You have successfully signed up to example.com,
your username is: gogo.<br/>
</p>
<p>
To login to the site, just follow this link: http://example.com/login.
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>

我是否需要将 Rails 应用程序上传到服务器或 Heroku 才能发送电子邮件?我知道 PHP 邮件和 MAMP/XAMPP 就是这种情况

最佳答案

设置不正确可能会导调用子邮件无法发送,且不会引发任何异常。假设您使用 SMTP 协议(protocol)来传送 main,您应该确保您已正确设置 ActionMailer configuration 。以下是使用 Gmail 的基本配置(通过 Rails Guides ):

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: '<username>',
password: '<password>',
authentication: 'plain',
enable_starttls_auto: true }

关于ruby-on-rails - Rails 应用程序可以从本地主机发送电子邮件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18541909/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com