Rails 3 sendgrid 支持无法发送电子邮件...尝试了我在网络上找到的所有内容...:P
所以我有一个 sendgrid 帐户,并且我正在尝试让 Rails 3 通过它发送电子邮件...以下是我的一些设置:
#development.rb
config.action_mailer.default_url_options = { :host => "smtp.sendgrid.net" }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => '587',
:domain => "place.com",
:authentication => :plain,
:user_name => "[email protected]",
:password => "password",
:enable_starttls_auto => true
}
我正在使用 Ubuntu Mint,并且 sendmail
可以发送电子邮件,我还可以成功 telnet 到 smtp.sendgrid.net 587
。
我尝试过各种其他随机组合,但均无济于事。有人有更多想法吗?
谢谢!
So I've got a sendgrid account, and I'm trying to get Rails 3 to send emails through it... Here are some of my settings:
#development.rb
config.action_mailer.default_url_options = { :host => "smtp.sendgrid.net" }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => '587',
:domain => "place.com",
:authentication => :plain,
:user_name => "[email protected]",
:password => "password",
:enable_starttls_auto => true
}
I'm using Ubuntu Mint, and sendmail
can send emails, I can also telnet into smtp.sendgrid.net 587
successfully.
I've tried all kinds of other random combinations of things to no avail. Anyone got any more ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试更改您的 postfix 配置文件以通过中继主机发送电子邮件。我猜您的 ISP 阻止了您的传出端口 25。请查看以下链接:
http://wiki.sendgrid.com/doku.php?id=postfix
Try altering your postfix configuration file to send emails via a relayhost. I'm guessing you're ISP is blocking your outgoing port 25. Check out the link below:
http://wiki.sendgrid.com/doku.php?id=postfix
我不确定你的问题是否和我的一样,但我在浪费了半天时间后才弄清楚如何使 SendGrid 工作。免责声明:我对 RoR 非常陌生 - 两三天前才开始玩简单的应用程序。我的问题似乎是只有新手才会遇到的问题……
不管怎样,闲话少说,事情就是这样的。我将推荐的行添加到environment.rb:
然后我尝试发送电子邮件并得到一个奇怪的行为:
事实证明我必须将 config.* 内容包含在以下内容中:
之后它就像魔术一样工作。希望这能有所帮助,如果不是你,至少还有其他一些不幸的新手......
编辑:
好吧,我说得太早了。通过上述修改,只有从 Rails 控制台调用 Emailer 时,我才能发送和接收电子邮件。如果我从应用程序内调用它,开发日志会显示电子邮件已发送,但我没有收到...控制台环境和应用程序之间有什么区别?请注意,当我按照 SendGrid 上的 postfix 说明并启动 postfix 时,电子邮件会从应用程序正常发送。
如果您找到问题的答案,请将其发布在这里...
I'm not sure whether your problem is the same as mine, but I just figured out how to make SendGrid work after wasting half a day on it. Disclaimer: I am VERY new to RoR - just started playing with simple apps two-three days ago. My problem seemed to be something that only a newbie can encounter...
Anyway, without further ado, this is what happened. I added the recommended lines to environment.rb:
Then I tried to send an email and got a strange behavior:
It turned out that I have to enclose the config.* stuff in the following:
It worked like magic after that. Hope this helps, if not you, some other hapless newbie at least...
EDIT:
Well, I spoke too early. With the modifications above I am able to send and receive the email ONLY if invoking the Emailer from the rails console. If I call it from within the app, the development log says the email was sent, but I don't receive it... What is the difference between the console environment and the app? Note that when I follow the postfix instructions on SendGrid and start postfix, the email gets send from the app alright.
If you have found the answer to your problem, please post it here...