gpt4 book ai didi

ruby-on-rails - Rails 邮件程序 Ubuntu

转载 作者:数据小太阳 更新时间:2023-10-29 07:36:48 26 4
gpt4 key购买 nike

在我的 Rails 应用程序(在 Mac 上运行)中,我使用了一个名为 pony 的 gem。当我通过小马创建消息时,我得到以下输出(在 Rails 控制台之外)。

#<Mail::Message:2186559360, Multipart: false, Headers: <Date: Tue, 13 Dec 2011 00:15:14 -0500>, <From: you@me.com>, <To: myself@hotmail.com>, <Message-ID: <4ee6df6288e90_30b080443b3c8148e@My-Name-MacBook-Pro.local.mail>>, <Subject: nothing>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>

此消息发送没有问题。

对于在 Ubuntu 上运行的单独应用程序,pony 向我抛出错误。

我没有发布错误,因为我切换到一个名为 mail 的 gem,它在发送消息后提供相同的输出(没有错误,控制台显示发送正常)。但问题是在 Ubuntu 系统上没有消息被发送。

我怀疑这是因为我从未在 Ubuntu 系统上设置邮件系统(如果这是编程世界中需要完成的操作)。如果是,我不确定我应该怎么做才能发送我的邮件。

我正在使用 Rails 3 和 Ubuntu Oneiric Ocelot。

最佳答案

您可以使用外部 SMTP 服务器,而不是依赖操作系统来使本地 sendmail 正常工作(OS X 可以,但我猜您的 Ubuntu 没有)。

对于测试和开发,您的 Gmail 可以工作:

Pony.mail(:to => 'you@example.com', :via => :smtp, :via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'user',
:password => 'password',
:authentication => :plain, # :plain, :login, :cram_md5, no auth by default
:domain => "localhost.localdomain" # the HELO domain provided by the client to the server
})

如果您从生产应用程序发送电子邮件,您可以使用来自 http://sendgrid.com/ 的廉价外部 SMTP 服务器.

关于ruby-on-rails - Rails 邮件程序 Ubuntu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8498586/

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