web*_*ebo 1 email postfix-mta actionmailer ruby-on-rails-3
我在开发模式下使用Ruby 1.9.2和Rails 3.0.4,我正在尝试将其配置为从安装在同一个盒子上的Postfix服务器发送电子邮件(运行安装了dovecot-postfix软件包的Ubuntu 10.04)每当我尝试从Rails发送电子邮件,它在Rails中干净利落地运行,但在Postfix日志中显示错误(我从下面的摘录中删除了域名和IP):
Feb 21 04:49:16 alpha postfix/smtpd[9060]: connect from alpha.mydomain.com[xxx.xxx.xxx.xxx]
Feb 21 04:49:16 alpha postfix/smtpd[9060]: lost connection after STARTTLS from alpha.mydomain.com[xxx.xxx.xxx.xxx]
Feb 21 04:49:16 alpha postfix/smtpd[9060]: disconnect from alpha.mydomain.com[xxx.xxx.xxx.xxx]
Run Code Online (Sandbox Code Playgroud)
奇怪的是,当我从像Thunderbird这样的电子邮件客户端连接到SMTP服务器时,它没有任何问题.
我知道开发模式有时不允许发送电子邮件,所以我将以下内容添加到environment/development.rb文件中:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
#load mail server settings
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "mail.mydomain.com",
:port => 587,
:domain => 'mydomain.com',
:user_name => 'username',
:password => 'password',
:authentication => 'plain',
:tls => true,
:enable_starttls_auto => true }
Run Code Online (Sandbox Code Playgroud)
tig*_*ris 11
如果您只是从localhost发送电子邮件,那么您不需要SMTP以及随附的所有身份验证问题.您可以直接使用sendmail进行交付.
config.action_mailer.delivery_method = :sendmail