问题描述
我正在尝试在 Rails 应用中发送电子邮件.如果我使用 Gmail,它可以工作,但如果我使用 Mandrill,它就不起作用.我在 Mandrill 上遇到了这个超时错误.不知道我做错了什么.对于 Gmail 和 Mandrill,我正在使用环境变量设置用户名和密码/api_key.两种设置之间的唯一区别是您在下面看到的内容.有任何想法吗?
I'm trying to send emails in a Rails app. It works if I use Gmail, but it's not working if I use Mandrill. I'm getting this timeout error with Mandrill. Not sure what I'm doing wrong. With both Gmail and Mandrill I am setting the username and password/api_key using environment variables. The only difference between the two setups is what you see below. Any ideas?
Timeout::Error in RegistrationsController#create
execution expired
Rails.root: /Users/michaeljohnmitchell/Sites/pre
Application Trace | Framework Trace | Full Trace
app/models/user.rb:38:in `send_welcome_email'
山魈不工作
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 25,
:user_name => ENV["MANDRILL_USERNAME"],
:password => ENV["MANDRILL_API_KEY"]
}
Gmail 工作
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
推荐答案
mandrill 使用 587 端口,我也遇到了同样的情况:)
use port 587 for mandrill, happend the same to me :)
这是因为端口 25 发送纯文本,端口 587 发送 SSL 编码的电子邮件(我认为这是整个 mandrill 的想法).
this is because port 25 is sending plain text and port 587 sends SSL encoded emails (which I think is the whole mandrill idea).
我不知道为什么他们在示例中将其设置为端口 25.
I have no idea why they set it to port 25 in their examples.
这篇关于无法让 Mandrill 从 Rails 应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!